Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

NullPointerException is not getting garbage collected properly in Multi threaded environment  RSS feed

 
ilangathir nagalingam
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • 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
 
fred rosenberger
lowercase baba
Bartender
Posts: 12441
42
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • 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?
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24215
37
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • 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?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!