Ticket #2555 (closed defect: fixed)
memory leaks in mapswf.c
| Reported by: | abajolet | Owned by: | assefa |
|---|---|---|---|
| Priority: | normal | Milestone: | 5.2 release |
| Component: | Output-SWF | Version: | svn-trunk (development) |
| Severity: | normal | Keywords: | |
| Cc: |
Description
Hello,
It seems that SWF (Flash) output leaks memory from various portions of code. From mapswf.c
* In function SWFShape gdImage2Shape(gdImagePtr img), adding
free(data);
before returning oShape corrects a serious leak. "data" is malloc() in gd2bitmap but not free() anywhere.
Tested with valgrind :
Before :
==2001== 307,593 bytes in 1 blocks are possibly lost in loss record 29 of 30 ==2001== at 0x40218B8: malloc (vg_replace_malloc.c:207) ==2001== by 0x80873FB: gd2bitmap (mapswf.c:385) ==2001== by 0x808776B: gdImage2Shape (mapswf.c:445) ... ==2001== possibly lost: 307,593 bytes in 1 blocks
After :
==13249== possibly lost: 0 bytes in 0 blocks
* When using true type labels, it seems the SWFFont ressources are not destroyed by msFreeImageSWF See the attached valgrind output file.
==13149== 60,733 (360 direct, 60,373 indirect) bytes in 5 blocks are definitely lost in loss record 42 of 56 ==13149== at 0x40218B8: malloc (vg_replace_malloc.c:207) ==13149== by 0x48F2F3E: newSWFFont (font.c:301) ==13149== by 0x48F2FE8: loadSWFFontFromFile (font.c:969) ==13149== by 0x80859D5: DrawText (mapswf.c:1633) ... ==13149== indirectly lost: 66,229 bytes in 77 blocks
The leak is very important, and in an Apache/PHP/php_mapscript context, the memory usage grows very quickly when the layers with labels are rendered.
* Environnement : Leaks tested with shp2img - Mapserver 5.0 SVN - Ming 0.3.0 Growing memory usage with Apache 2.2.x, PHP 5.2.5, php_mapscript
Regards, Antoine Bajolet

