Garbage being collected?
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
I've heard it takes forever to grow a woman from the ground
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
I'm not able to understand your scenario.....very sorry for that !!
If possible, please provide some code snippet to watch out here.
Thanks
SCJP1.4(96%)<br />A drop of ink can make millions think.
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
- Peter
Peter den Haan | peterdenhaan.com | quantum computing specialist, Objectivity Ltd
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
-
-
Number of slices to send:Optional 'thank-you' note:
-
-

Peter den Haan | peterdenhaan.com | quantum computing specialist, Objectivity Ltd
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
I've heard it takes forever to grow a woman from the ground
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
).Remember it's not guaranteed to run.
42
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
A common misconception. It is guaranteed to run before an OutOfMemoryError is thrown, as the javadoc states that it is "thrown when the Java Virtual Machine cannot allocate an object because it is out of memory, and no more memory could be made available by the garbage collector." (my emphasis). You cannot run out of memory simply through creating lots of object churn.Originally posted by Jeroen Wenting:
Remember it's not guaranteed to run.
- Peter
Peter den Haan | peterdenhaan.com | quantum computing specialist, Objectivity Ltd
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
If the objects are somehow not loosing references they will never be garbage collected (luckily the Java GC is smart enough to catch entire groups of objects with no outside references so that leak option has been plugged).
There is also the possibility that the garbage collector will fail to run if memory is used up so quickly that the JVM doesn't have enough resources left to run the GC in.
Or maybe the programmer thought to be smart and run a thread at maximum priority, leaving it at a scheduling priority higher than the GC itself thus preventing the GC from running before it's too late.
42
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Originally posted by Peter den Haan:
Pedant![]()
My wife does call me a "pedantic literalist"... how'd you know?
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
What use is a bald assertion? Prove it. Produce a reference, show the entry in the bug database, provide demonstration code, and/or explain why the javadoc I quoted above does not imply that the garbage collector is runs before the error is thrown.Originally posted by Jeroen Wenting:
you CAN run out of memory by creating a load of objects, the garbage collector just makes it less likely and take longer.
Then they are not "no longer reachable by any thread", are they? I don't think anyone is unclear on this.If the objects are somehow not loosing references they will never be garbage collected (luckily the Java GC is smart enough to catch entire groups of objects with no outside references so that leak option has been plugged).
Object churn is not enough. Even creating moderately bulky objects at high thread priority in a tight loopIs not enough. Try it.
- Peter
[ July 28, 2004: Message edited by: Peter den Haan ]
Peter den Haan | peterdenhaan.com | quantum computing specialist, Objectivity Ltd
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Originally posted by Jeroen Wenting:
There is also the possibility that the garbage collector will fail to run if memory is used up so quickly that the JVM doesn't have enough resources left to run the GC in.
Or maybe the programmer thought to be smart and run a thread at maximum priority, leaving it at a scheduling priority higher than the GC itself thus preventing the GC from running before it's too late.
Where do you get this from???
I don't think that the specification allows such behaviour; and it would be rather easy to prevent, so I would be surprised if there were a JVM in which the above could happen...
uzzled:The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
| There is no greater crime than stealing somebody's best friend. I miss you tiny ad: Paul Wheaton's 16th Kickstarter: Gardening playing cards for gardeners and homesteaders https://coderanch.com/t/889615/Paul-Wheaton-Kickstarter-Gardening-playing |








