Question about mono_array_new #112855
-
What is the lifetime of the array created using mono_array_new? How can I ensure it persists for later use, and how can I manually release the memory when it's no longer needed? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Mono's GC does a conservative scan to find objects. Once you have registered your thread with To make a persist storage for latter use, you need to report the storage of the pointer with GC will take care of releasing it and you can't do it manually. See https://www.mono-project.com/docs/advanced/garbage-collector/sgen/#stopping-the-world and https://www.mono-project.com/docs/advanced/garbage-collector/sgen/#roots |
Beta Was this translation helpful? Give feedback.
The mono project document is somehow aged.
mono_gc_register_root
registers a region of memory to mono, indicates the content within it should be conservatively treated as gc roots. Once you put an object pointer into it, the object will be preserved.mono_gchandle_new_v2
is new fashioned and should be used.