0
5

Automatically unload all modules and free up memory on VM release.

Dieser Commit ist enthalten in:
Rafal Kupiec 2018-07-19 07:35:59 +02:00
Ursprung ee5504ea3a
Commit 5908307885
Signiert von: belliash
GPG-Schlüssel-ID: 4E829243E0CFE6B4

8
vm.c
Datei anzeigen

@ -1465,6 +1465,14 @@ PH7_PRIVATE sxi32 PH7_VmReset(ph7_vm *pVm) {
* Every virtual machine must be destroyed in order to avoid memory leaks. * Every virtual machine must be destroyed in order to avoid memory leaks.
*/ */
PH7_PRIVATE sxi32 PH7_VmRelease(ph7_vm *pVm) { PH7_PRIVATE sxi32 PH7_VmRelease(ph7_vm *pVm) {
VmModule *pEntry;
/* Iterate through modules list */
while(SySetGetNextEntry(&pVm->aModules, (void **)&pEntry) == SXRET_OK) {
/* Unload the module */
dlclose(pEntry->pHandle);
}
/* Free up the heap */
SySetRelease(&pVm->aModules);
/* Set the stale magic number */ /* Set the stale magic number */
pVm->nMagic = PH7_VM_STALE; pVm->nMagic = PH7_VM_STALE;
/* Release the private memory subsystem */ /* Release the private memory subsystem */