Good question.
I suggest you don't use MemoryDLLOpen/...Call/...Close anymore, but the MemLib-functions contained in this UDF.
Something like this is better since we have DLLCallAddress:
$hMod = MemLib_LoadLibrary(...)
$pFunc = MemLib_GetProcAddress($hMod, "SomeFunc")
$aRet = DLLCallAddress("int", $pFunc, "str", "param1", ...)
MemLib_FreeLibrary($hMod)