It shouldn't be, because there will be a reference on the native stack or 
machine registers between step1 and step2 and those areas will be scanned by 
the garbage collector.


-Bernhard

________________________________________
From: Mono-devel-list <mono-devel-list-boun...@lists.dot.net> on behalf of 
xiaozhu <niluzhou1...@foxmail.com>
Sent: Friday, April 6, 2018 12:42:48 PM
To: mono-devel-list
Subject: [Mono-dev] how-to-protect-object-created-by-mono-object-new-from-gc

hi,all:

I embed the mono in my game engine.And create managed object by invoke 
mono_object_new then call mono_gchandle_new to ref the object.

step1:

MonoObject* monoObject= mono_object_new()

step2

uint32_t objectHandle = mono_gchandle_new(monoObject,false);

Will monoObject be gabage collected between step1 and step2? If yes how to 
prevent it.


Thanks.
_______________________________________________
Mono-devel-list mailing list
Mono-devel-list@lists.dot.net
http://lists.dot.net/mailman/listinfo/mono-devel-list

Reply via email to