2

I'm trying to allocate memory dynamically in my code and release them ,I tried to use zend_mm but I couldn't add it to php 7,I'm using php 7.4 and xampp server , if it is impossible please tell my the Alternatives to do that.

the problem is ,I try to use rundll to execute some c functions from dll library ,but the rundll doesn't return output from functions so ,I try to reserve some memory from ram and run the rundll command by exec() php function ,passing the address to reversed memory to function, then the function writes its output on this memory so ,I can get the output after the function ends

steps : 1- php reserve some memory from ram . 2- php open cmd and run the rundll to call c function. 3- c function writes output in reserved memory . 4- php can got the output.

6
  • Does this answer your question? PHP Memory Allocation and Deallocation
    – kavigun
    Commented Sep 25, 2020 at 15:45
  • @kavigun This doesn't seem to be related. He's trying to interface with an external DLL, not just using PHP variables.
    – Barmar
    Commented Sep 25, 2020 at 15:48
  • exec() is for running shell commands, it creates a new process and doesn't use the memory of the current process.
    – Barmar
    Commented Sep 25, 2020 at 15:49
  • zend_mm as I understand is a part of PHP's internals, so it's there already. PHP automatically allocates blocks of memory, in response to what your code is doing, up to the limit of your memory_limit. I'm not aware of an out-of-the-box means for custom memory allocation and access. Is there no other way you can return output from your dll? Could write a wrapper for it that returns the output to PHP.
    – Markus AO
    Commented Sep 25, 2020 at 16:03
  • 1
    no this link isn't useful there are to different things , here i want to make like new and delete in c++ or alloc() and free() in c . i want to use the memory freely reserving it and freeing it by myself
    – M.sharf
    Commented Sep 25, 2020 at 16:10

0

Browse other questions tagged or ask your own question.