A question about moving GC

Unknown W. Brackets unknown at simplemachines.org
Sat Jun 3 11:09:56 PDT 2006


Typically, garbage collectors run only on memory 
allocation/deallocation/similar.  They won't run in the middle of a 
foreign program... unless it's threaded, then all bets are off.

-[Unknown]


> How to ensure D code that interoperates with external libraries will
> work when a moving gc is eventually used with D? Will i need to add
> lots of pinning/unpinning code?
> 
> extern(C) external(Foo* foo); 
> 
> struct Foo
> {
> }
> 
> class Bar
> {
> 	Foo foo;
> }
> 
> main()
> {
> 	Foo* foo = new Foo();
> 	
> 	// Should foo be pinned before the call?
> 	external(foo);
> 
> 	Bar bar = new Bar();
> 
> 	// Should bar be pinned before the call?
> 	external(&bar.foo);
> }
> 
> 
> btw, ares seems to provides a moving gc and does have a gc.pin method.
> Should i consider looking closer at ares? Thanks



More information about the Digitalmars-d-learn mailing list