• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

NullPointerException is not getting garbage collected properly in Multi threaded environment

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Friends,

I have written a thread program which is keep on running. In that thread i am catching NullpointerException in a single place.
When i did memory profiling i got more than one lakh objects of NPE is available in memory.
My doubt is when this NullPointerException will be getting garbage collected. Will JVM wait to complete the thread execution?
Please help me on this.

Thanks,
Ila
 
lowercase baba
Posts: 13089
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
what do you mean by 'properly'?

There is no guarantee that I know that states how quickly something will be garbage collected. My understanding is that all you can be sure of is that it will run at least once before you get an out of memory exception.

Is your application running out of memory? getting close to running out of memory? If not, I wouldn't worry about it. Since the JVM still has memory, available, why should it waste time cleaning up?
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Welcome to JavaRanch!

Fred's absolutely right that objects won't generally be collected until their memory is needed, but it still seems odd to me that there are 100,000 NPE objects in memory. What code is creating all these exceptions? And are you putting them in a Collection somewhere?
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic