snowkit / hxcpp-guide

A guide for the Haxe CPP target build systems, CFFI and APIs
80 stars 8 forks source link

Tear down call for hxcpp? #6

Open kevinresol opened 7 years ago

kevinresol commented 7 years ago

I would like to know corresponding tear-down calls for the following setup calls?

extern "C" void hxcpp_set_top_of_stack();
extern "C" const char *hxRunLibrary();
kevinresol commented 7 years ago

Because I am trying to embed hxcpp code into an existing application. I would have to start the hxcpp part by calling hxRunLibrary and have to tear down properly so I can start again later. @hughsando any advice?

kevinresol commented 7 years ago

ping @underscorediscovery @hughsando

hughsando commented 7 years ago

There is no really good way to tear-down everything. It is something I have been thinking about, but it is not trivial and would take some work. For example - would you expect to reset the statics back to their initial values?

Two things you can do to reduce resources are to call cpp.vm.gc.compact() to free as much memory as possible. You will need HXCPP_GC_MOVING defined to make the most of this.

Detach the main thread using: hx::SetTopOfStack((int *)0,true); Currently, you will need to use and external code method to call this.