Re: [Mono-list] Embedded API. Numeric Boxing and GC

2014-02-26 Thread Rodrigo Kumpera
This code is wrong, it will fail when the object is moved since the gchandle is not pinning the target. Avoid pinning as much as possible since it does hurt performance a lot. The solution is to remove the monoObject field and use mono_gchandle_get_target against the GC handle. On Tue, Feb 25,

Re: [Mono-list] Embedded API. Numeric Boxing and GC

2014-02-26 Thread jonat...@mugginsoft.com
On 26 Feb 2014, at 16:15, Rodrigo Kumpera kump...@gmail.com wrote: This code is wrong, it will fail when the object is moved since the gchandle is not pinning the target. Avoid pinning as much as possible since it does hurt performance a lot. The solution is to remove the monoObject

Re: [Mono-list] Embedded API. Numeric Boxing and GC

2014-02-26 Thread Rodrigo Kumpera
On Wed, Feb 26, 2014 at 12:58 PM, jonat...@mugginsoft.com jonat...@mugginsoft.com wrote: On 26 Feb 2014, at 16:15, Rodrigo Kumpera kump...@gmail.com wrote: This code is wrong, it will fail when the object is moved since the gchandle is not pinning the target. Avoid pinning as much as

[Mono-list] Embedded API. Numeric Boxing and GC

2014-02-25 Thread jonat...@mugginsoft.com
I box my numeric primitives using a macro: #define DB_BOX_INT64( x ) ( mono_value_box(mono_domain_get(), mono_get_int64_class(), x) ) And use it like so: 1. - (void)box { MonoObject *monoObject = DB_BOX_INT64(value); } I save the MonoObject * into a local variable. The collector will see

Re: [Mono-list] Embedded API. Numeric Boxing and GC

2014-02-25 Thread Robert Jordan
On 25.02.2014 11:20, jonat...@mugginsoft.com wrote: I box my numeric primitives using a macro: #define DB_BOX_INT64( x ) ( mono_value_box(mono_domain_get(), mono_get_int64_class(), x) ) And use it like so: 1. - (void)box { MonoObject *monoObject = DB_BOX_INT64(value); } I save the

Re: [Mono-list] Embedded API. Numeric Boxing and GC

2014-02-25 Thread jonat...@mugginsoft.com
On 25 Feb 2014, at 12:18, Robert Jordan robe...@gmx.net wrote: On 25.02.2014 11:20, jonat...@mugginsoft.com wrote: Is the above correct? Not quite. Look at this line: self.monoObject = DB_BOX_INT64(value); There is a chance that the MonoObject* remains only reachable from