1. Club Seiden uses Gitter chat for day to day discussion. If you are a member of Github you just need to ask to join our Github organization: https://github.com/club-seiden and join us on the Gitter.IM chat page!
    Dismiss Notice

Memory leak under PHP 7

Discussion in 'PHP Toolkit' started by Scott Rycroft, Aug 29, 2017.

  1. Scott Rycroft

    Scott Rycroft New Member

    I am experiencing what appears to be a memory leak when running under PHP 7 / Zend Server 9.1. It appears that any toolkit call increases memory usage by the plug size. We ran into this after calling programs in a loop for a result set. It doesn't appear to matter what the toolkit call is - it could be a program/procedure call or a CL command.

    I've attached a minimum reproducible program where you can see memory usage increasing by the plug size until the memory limit is reached. Running the same code under PHP 5 / ZS 8.5 does not produce this issue.

    I've duplicated this on different systems as well.

    Has anyone else run into this or have any ideas?

    PHP 7 / ZS 9.1
    memLeakPHP7.png

    PHP 5.6 / ZS 8.5
    memLeakPHP5.png
     

    Attached Files:

  2. Alan

    Alan Administrator Staff Member

    Thanks for posting this, Scott. Looks like an interesting one.
     
  3. Alan

    Alan Administrator Staff Member

    Scott, I heard from Chelsea that the out-of-memory error occurs on the db2_execute() line, right?
     
  4. Scott Rycroft

    Scott Rycroft New Member

    Yes that's correct
     
  5. Alan

    Alan Administrator Staff Member

  6. Scott Rycroft

    Scott Rycroft New Member

    Thanks! I couldn't reproduce it without the toolkit, but it makes sense that it's likely an ibm_db2 issue.
     
  7. Alan

    Alan Administrator Staff Member

    Scott, it's most likely a PHP 7 garbage collection issue, actually. Not ibm_db2.
     
  8. Alan

    Alan Administrator Staff Member

    The bound variables should be garbage-collected when the function ends and the variables go out of local scope. That's PHP 7's job. It's possible that PHP 7 employs a sort of lazy garbage collection for the sake of performance, in which case it could be an issue of GC timing, or PHP 7 doesn't know the size of the output string in advance. Just conjecture, though.

    By the way, did you ever come up with a workaround? If not then I may have a suggestion.
     
  9. Scott Rycroft

    Scott Rycroft New Member

    Thanks Alan. Regarding GC I did try calling gc_collect_cycles() but it had no effect.
    I don't have a workaround at this time.
     

Share This Page