

Memory Leak Torpedoed Princeton's DARPA Chances - abarrera
http://www.codeproject.com/showcase/IfOnlyWedUsedANTSProfiler.asp

======
stevei
Pretty misleading title - the issue wasn't a C# memory leak, it was that these
developers didn't remove old objects from an event subscriber list...

~~~
boucher
Perhaps, but it points out the often overlooked truth that using a garbage
collected language is substituting one set of memory problems for another. I
can't tell you how much of my time at work is spent trying to work around the
java garbage collector because I can't manually destroy objects.

~~~
wyday
> Perhaps

No, the title _is_ misleading. It was misleading on reddit too.

> ... because I can't manually destroy objects.

I'm not sure about Java, but if it's similar to C# then you can manually
destroy objects. When they get "officially" removed from memory is up to the
garbage collector (that is, when more memory space is needed).

~~~
boucher
Also, its worth noting that you can not reclaim the memory of an object in
Java, C# (<http://blogs.msdn.com/clyon/archive/2004/09/21/232445.aspx>), or
any other garbage collected language. If you could, you would no longer have
managed code. What you may be able to do in some languages is say "hey GC,
I've got this object, I know its got no references, verify that and free the
space now please". You can't do this in Java (or C# so far as I know). This is
what I meant when I said destroy.

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.

~~~
queensnake
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'...

~~~
boucher
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.

------
abarrera
Truth to be said, the title comes from slashdot, but hey guys, why argue about
the title when the content is cool? I enjoyed the article and just for the
record, I did understand the problem was a user memory leak and not something
to do with C#.

~~~
wyday
> the title comes from slashdot

That explains it. From a site that uses a photoshop of Bill Gates/Borg hybrid
for every Microsoft story, it's no wonder the title's misleading.

------
kirse
And if you call right now with the ANTS Profiler you'll get not just ONE
license, but TWO licenses for 5 easy payments of $59.95. BUT THAT'S NOT ALL!!
We'll throw in this FREE Profiler coffee mug, absolutely free! Operators are
standing by!

~~~
wyday
Oh please, we're all whores. This story would only be spam if it were
contrived to sell more ANTS software.

~~~
michaelneale
You will probably get down modded, but you are right. We are all whores of
some sort, some of the time at least. Its actually liberating to make this
realisation, and get over ourselves.

