04-18-2019, 07:26 PM
Hi Richard!
I'm not a C# expert, but I'll try to help. You should not be worried about the GC destroying anything. All references to returned Tilengine objects are IntPtr encapsulated insie a struct. Both items (IntPtr and structs) are value types that exist in the stack, so they do not have the memory allocation lifecycle of object types. They cannot be automatically finalized or garbage collected. In other words, if you don't explicitly delete/deinit tilengine instances by calling Delete() (or Deinit()) on them, they will stay forever, nobody will destroy them for you.
I don't know how Unity handles external libraries, but you should never do TLN_Deinit() or TLN_DeleteContext() if someone is still trying to draw. They should be the very last calls before unloading the library.
I'm not a C# expert, but I'll try to help. You should not be worried about the GC destroying anything. All references to returned Tilengine objects are IntPtr encapsulated insie a struct. Both items (IntPtr and structs) are value types that exist in the stack, so they do not have the memory allocation lifecycle of object types. They cannot be automatically finalized or garbage collected. In other words, if you don't explicitly delete/deinit tilengine instances by calling Delete() (or Deinit()) on them, they will stay forever, nobody will destroy them for you.
I don't know how Unity handles external libraries, but you should never do TLN_Deinit() or TLN_DeleteContext() if someone is still trying to draw. They should be the very last calls before unloading the library.