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.

M.sharf
  • 21
  • 3
  • Does this answer your question? [PHP Memory Allocation and Deallocation](https://stackoverflow.com/questions/17816767/php-memory-allocation-and-deallocation) – kavigun Sep 25 '20 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 Sep 25 '20 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 Sep 25 '20 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 Sep 25 '20 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 Sep 25 '20 at 16:10
  • Sounds like you want to be writing a PHP extension, not PHP code. – Sammitch Sep 25 '20 at 18:25

0 Answers0