PHP Classes

Memory leak -- how to fix?

Recommend this page to a friend!

      Polygon  >  All threads  >  Memory leak -- how to fix?  >  (Un) Subscribe thread alerts  
Subject:Memory leak -- how to fix?
Summary:Unsure is polygon library is leaking, or is my usage...
Messages:1
Author:Jeff Hoppe
Date:2012-01-10 14:20:50
 

  1. Memory leak -- how to fix?   Reply   Report abuse  
Picture of Jeff Hoppe Jeff Hoppe - 2012-01-10 14:20:50
I've encountered a situation with runaway memory using the polygon library, causing a script I've written to exhaust the available memory allocated to a php process and unexpectedly terminate.

My program, in a nutshell, parses a GPS lat/lon feed coming into a mySQL database, does some point-in-polygon (using the polygon library) tests, and assigns the GPS coordinate to a particular polygon based upon the results of the PIP test.

The issue I'm encountering is that, when I uncomment all of the polygon library stuff (leaving only a while(1) loop and some mySQL calls), php's memory usage stays at a constant 16MB. When I use the polygon library, memory runs away until I pop the 128MB limit and the program terminates.

I've tried unset() on my polygon variables when they're no longer in use, as well as setting them to null, and combinations of those as well. It seems no amount of "manual memory management" is working.

Could there be a possible memory leak in the polygon program, or is there some other way to manage memory effectively? This php program will run constantly and indefinitely, creating and destroying polygon objects which to test GPS coordinates against. Is this possible?

I can provide code if needed.