Problems with GC, trees and array concatenation

Paolo Invernizzi arathorn at NO_SPAMfastwebnet.it
Sun Jun 3 12:46:08 PDT 2007


Oskar Linde wrote:

> There will 
> almost always be some spurious pointers. Allocating large arrays (such 
> as what happens behind the scenes when doing array concatenation) will 
> always carry a risk of allocated memory being hit by a spurious pointer.

I don't understand. Where are the spurious pointers coming in the above 
example?

> The risk of your application having runaway or contained memory leaks 
> depend on the allocation patterns you have, but in general, the larger 
> your objects (like arrays) are, the larger the chance that you need to 
> handle their memory manually. The problem is increased if you have many 
> objects containing mixed pointer and non-pointer, but apparantly random 
> data.

Again, I don't understand. I don't see any random data.


> So in conclusion, I am quite sure the following line:
> 
>              indi[] = testPop1.individuals ~ testPop2.individuals;
> 
> Is the cause of the memory leak, because it allocates a huge chunk of 
> memory that is left to the GC to free. The chance of those huge chunks 
> being hit by a spurious pointer seems quite high.

This is a nonsense. What's the meaning of having a garbage collector if, 
huge or not huge, it cannot free a block of memory is a so pretty linear 
example? For sure, I'm missing something...

Walter?

Cheers, Paolo.



More information about the Digitalmars-d mailing list