Garbage collector collects live objects

Ruslan Mullakhmetov via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Dec 9 05:54:47 PST 2014


Hi,

I experience very strange problem: GC somehow collects live 
objects.

I found it because i got segfaults. After debugging and tracing i 
found this is because of accessing not allocated memory.

I did the following checks:

- added to some class invariant check for access to suspicious 
members with assertion

assert(GC.addrOf(cast(void*)x) !is null);


where it fails DETERMINISTICALLY at some point

- printing address of allocated classes where i observe the 
following pattern

-> ctor
      check
      check
      check
<- dtor
      check (fails)

could anybody advice me with something? I got really frustrated 
by this strange behaviour which i can not fix right now.

key observations:
- it is deterministically behaviour (what gets me even more 
confused cause GC collections as far as i know runs from time to 
time)
- i do not play with pointers optimisation like hiding its in 
ints or floats.
- i operate with large uniformly distributed (video) data in 
memory where pointer like patterns may occur. but this is not the 
case cause (1) it brings at worst long living objects (2) input 
sequence constant but allocated pointers each run different.



More information about the Digitalmars-d-learn mailing list