Results 1 to 9 of 9
Thread: memory leaks in Java
- 09-28-2010, 09:06 PM #1
Member
- Join Date
- Sep 2010
- Posts
- 11
- Rep Power
- 0
- 09-28-2010, 10:21 PM #2
One sort of memory leak is an object that isn't being used but still has a reference to it being held somewhere. For example unused listeners can often be left attached when they should have been removed.
Avoid by good programming practices. If you open a file, close it. If you add a listener, remove it.
- 09-28-2010, 10:29 PM #3
Member
- Join Date
- Sep 2010
- Posts
- 11
- Rep Power
- 0
Is this the only type of memory leak or there are any other type of memory leaks.One method is using garbage collection .The other one is as you said Norm. What type of memory leaks we encounter with collections.
Thanks in advance
Navatha
- 09-29-2010, 07:36 AM #4
Garbage collection is not a method of creating memory leaks. Garbage collection removes unused blocks of memory so that memory does NOT leak.
How does garbage collection work?
- 09-29-2010, 08:30 AM #5
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,603
- Blog Entries
- 7
- Rep Power
- 17
- 09-29-2010, 09:31 AM #6
Moderator
- Join Date
- Apr 2009
- Posts
- 10,484
- Rep Power
- 16
The solution to that is to never write stuff in a finalize()...:)
That really is a red flag warning during a code review.
- 09-29-2010, 05:56 PM #7
Agreed with Tolls. That's not the garbage collector's fault, that's a bad coder's fault. ;)
- 09-29-2010, 06:39 PM #8
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,366
- Rep Power
- 8
You'd be surprised, however, how often people use finalize, though. And i almost always leads to these types of problems.
- 09-29-2010, 06:42 PM #9
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,603
- Blog Entries
- 7
- Rep Power
- 17
Similar Threads
-
Java Memory Issue
By personal in forum Advanced JavaReplies: 12Last Post: 01-07-2012, 02:05 PM -
how do I increase memory allocated to code cache (Non Heap Memory)
By manibhat in forum Advanced JavaReplies: 2Last Post: 08-21-2008, 07:33 PM -
Axis 1.4 xerces memory leaks
By hlaprade in forum Advanced JavaReplies: 0Last Post: 12-11-2007, 12:42 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks