Re: Garbage Collection
- From: "Mark A. Andrews" <KE4MA@xxxxxxxxx>
- Date: Wed, 16 Jan 2008 10:59:15 -0600
Eric Grange wrote:
Huh? What are you talking about?
Letting the GC be able to recycle the memory of parts of a collection/datastructure before the whole collection/datastructure itself leaves the scope.
If you're only dealing with small collections/datastructures (relatively to available memory) that's not an issue, but whenever that's not the case, that's IME the #1 source of memory usage "bloat" in your typical .Net/Java apps, leading to "spikes" in memory usage until the whole processing has completed.
F.i. one recently encountered situation, if you have something like
{
list = new ListOfSomething()
for all item in list
item.DoSomeStuff()
}
where DoSomeStuff() involves allocation of memory referred in item (such as data being pulled from a DB, work structures, etc.), said memory won't be recoverable until the for loop has ended, unless the loop is changed to include nil'ing:
list[index].DoSomeStuff()
list[index] = nil;
which would be a list[index].free in a non-GC world.
Of course that can be a little more involved to solve if instead of a list, you actually get an iterator that maintains the list internally...
Eric
Good example. Say some programmer with a limited data set and a non-deterministic garbage collector has to iterate through this 10 times during testing. No problem, the ndgc works fine. But when you put that same situation in the real world where you might have to iterate through 50,000 items, periodically the user is going to curse the computer when he can't move the mouse because some background garbage collection process steals his cpu while managing all this memory that has been abandoned.
I anticipate that some of you will come back and say "Well then he should just go ahead and deallocate the memory manually in the process.." to which I will reply "Then what's the point of having a non-deterministic garbage collector?"
I repeat, good coding practice and a good, well-defined software engineering process is the best garbage collector.
Mark
.
- References:
- Garbage Collection
- From: Sanyin
- Re: Garbage Collection
- From: Eric Grange
- Re: Garbage Collection
- From: Rudy Velthuis [TeamB]
- Re: Garbage Collection
- From: Eric Grange
- Garbage Collection
- Prev by Date: Re: EU is on the loose.
- Next by Date: Re: Well... Borland on YouTube
- Previous by thread: Re: Garbage Collection
- Next by thread: Re: Garbage Collection
- Index(es):
Relevant Pages
|
Loading