Re:Memory Leak Torpedoed Princeton's DARPA Chances
by imsteve on Saturday November 17, 2007 @06:40PM
(#81049)
> you can not reclaim the memory of an object in Java, C#, or any other garbage collected language.
That's just not true. Python currently doesn't return memory from space allocated to primitive types but there's a branch that I'm using that will do that too which will be merged to that main soon. That's a pretty broad statement you're making.
Re:Memory Leak Torpedoed Princeton's DARPA Chances
by queensnake on Saturday November 17, 2007 @03:41PM
(#81013)
Could you / do you use memory (object) pools? It's crazy to put C++ techniques on top of Java which is supposed to take all that off your hands but, as you say, 'in the real world'...
Re:Memory Leak Torpedoed Princeton's DARPA Chances
by boucher on Saturday November 17, 2007 @06:21PM
(#81040)
We use a lot of thread local pools so that we never allocate new objects. We generally have a fixed number of long lived threads, so this works out pretty well.
Re:Memory Leak Torpedoed Princeton's DARPA Chances
by Tichy on Sunday November 18, 2007 @12:56PM
(#81249)
That just seems like very bad practice. System.gc() usually does not do anything, and it might seem as if a lot of memory is being used. Usually the gc kicks into gear if the memory is really needed, though.
Don't know the OS X jvm, but it can't be THAT bad...
I had some troubles with mobile phone JVMs, usually manually setting all pointers to null was doing the trick, though.
In any case, I wouldn't blame Java for some bad implementations of jvms.
Why might someone need that level of control? Well in an ideal world you would not, but in reality (at least in Java), GC is highly JVM dependent, and on the JVM I use (and probably most if not all of them) GC makes no guarantee that objects available for collection will actually be collected. The OS X JVM in particular is pretty bad here (again, I'm guessing others are too), when you run out of memory, it doesn't even try to GC. Even if you call System.gc() you might not get any space reclaimed. Its ridiculous, but lots of people actually have a method that is basically "System.reallyGC()" which loops a whole bunch of times on System.gc() calls until it either gives up or reclaims some percentage of memory.