Opened 16 years ago
Closed 16 years ago
#2724 closed defect (fixed)
Resource leak
Reported by: | brage | Owned by: | dmorissette |
---|---|---|---|
Priority: | normal | Milestone: | 5.4 release |
Component: | MapScript-PHP | Version: | unspecified |
Severity: | normal | Keywords: | |
Cc: | sdlime |
Description
If a php/mapscript application opens a layer with LayerObj::open() and forget to call Layerobj::close(), the resources are not cleaned up upon request end.
If for example the layer is a shapefile layer, the file descriptors are left open, and a long running apache process with a buggy php script may use all available file descriptors on a system, and in the worst case making the system crash.
I have no idea if this affects the other scripting languages, but a general fix might be to let freeLayer() in mapfile.c close the layer if it is open.
Attachments (1)
Change History (4)
by , 16 years ago
Attachment: | patch-resource-leak added |
---|
comment:1 by , 16 years ago
Component: | MapServer C Library → MapScript-PHP |
---|---|
Owner: | changed from | to
comment:2 by , 16 years ago
Cc: | added |
---|---|
Milestone: | → 5.4 release |
Owner: | changed from | to
Status: | new → assigned |
comment:3 by , 16 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Fixed in SVN trunk r7841.
I have reproduced the leak and verified that it's gone with Valgrind using a script that does repeated calls to
$map = ms_newMapObj("/path/to/test.map"); $layer = $map->getLayer("layername"); $layer->open(); $map = ms_newMapObj("/path/to/test.map"); $layer = $map->getLayer("layername"); $layer->open(); $map = ms_newMapObj("/path/to/test.map"); $layer = $map->getLayer("layername"); $layer->open(); ...
This probably affects all MapScript versions. The proposed fix makes complete sense and should not have any unintended side-effect. I'll take care of this in the 5.4 (trunk) version.