Opened 20 years ago
Closed 19 years ago
#713 closed defect (fixed)
mapraster memory leaks
Reported by: | Owned by: | warmerdam | |
---|---|---|---|
Priority: | high | Milestone: | 4.4 release |
Component: | MapServer C Library | Version: | 4.3 |
Severity: | normal | Keywords: | |
Cc: |
Description
Mapraster has a memory leak drawing tiled raster layers caused by not properly freeing temporary layer. The memory leak was tested using Softpixel MemCheckDeluxe v1.2.2 It can be found at http://prj.softpixel.com/mcd/, and it quite usefull and easy to include in any project (also it has BSD style license).
Attachments (1)
Change History (5)
by , 20 years ago
Attachment: | mapraster.patch.txt added |
---|
comment:1 by , 20 years ago
Cc: | added |
---|---|
Owner: | changed from | to
Reassigned to Frank, the owner of mapraster.c
comment:2 by , 20 years ago
Milestone: | → 4.4 release |
---|---|
Status: | new → assigned |
This needs to be reviewed and applied in time for 4.4. The tricky part is reproducing the leak. From the patch it would appear the leaking only occurs in error handling cases.
comment:3 by , 19 years ago
I did a run with one of the raster tile files running under valgrind and it was clean, no leaks. But I ran with the tile index itself missing and got the following: ==2222== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 64 from 1) ==2222== malloc/free: in use at exit: 91858 bytes in 11 blocks. ==2222== malloc/free: 1376 allocs, 1365 frees, 743710 bytes allocated. ==2222== For counts of detected errors, rerun with: -v ==2222== searching for pointers to 11 not-freed blocks. ==2222== checked 19440216 bytes. ==2222== ==2222== 5 bytes in 1 blocks are still reachable in loss record 1 of 11 ==2222== at 0x1B903A80: malloc (vg_replace_malloc.c:131) ==2222== by 0x4DD8FF: strdup (in /lib/tls/libc-2.3.3.so) ==2222== by 0x80C89D5: msDrawRasterLayerLow (mapraster.c:1303) ==2222== by 0x8077ACB: msDrawRasterLayer (mapdraw.c:1116) ==2222== by 0x8076402: msDrawLayer (mapdraw.c:754) ==2222== by 0x8075548: msDrawMap (mapdraw.c:419) ==2222== by 0x804E280: main (shp2img.c:200) ==2222== ==2222== ==2222== 9 bytes in 1 blocks are still reachable in loss record 2 of 11 ==2222== at 0x1B903A80: malloc (vg_replace_malloc.c:131) ==2222== by 0x4DD8FF: strdup (in /lib/tls/libc-2.3.3.so) ==2222== by 0x8055086: initLayer (mapfile.c:2156) ==2222== by 0x80C89BD: msDrawRasterLayerLow (mapraster.c:1300) ==2222== by 0x8077ACB: msDrawRasterLayer (mapdraw.c:1116) ==2222== by 0x8076402: msDrawLayer (mapdraw.c:754) ==2222== by 0x8075548: msDrawMap (mapdraw.c:419) ==2222== by 0x804E280: main (shp2img.c:200) ==2222== ==2222== ==2222== 16 bytes in 1 blocks are still reachable in loss record 3 of 11 ==2222== at 0x1B9043FD: calloc (vg_replace_malloc.c:176) ==2222== by 0x5BB308: _dlerror_run (in /lib/libdl-2.3.3.so) ==2222== by 0x5BAED0: dlsym (in /lib/libdl-2.3.3.so) ==2222== by 0x1C358C6F: __errno_location (vg_libpthread.c:2127) ==2222== by 0x1B996296: pj_init (pj_init.c:233) ==2222== by 0x8051552: msProcessProjection (mapfile.c:912) ==2222== by 0x805BCD6: initMap (mapfile.c:4005) ==2222== by 0x805C75C: loadMapInternal (mapfile.c:4189) ==2222== by 0x805D7CD: msLoadMap (mapfile.c:4407) ==2222== by 0x804DB75: main (shp2img.c:80) ==2222== ==2222== ==2222== 20 bytes in 1 blocks are still reachable in loss record 4 of 11 ==2222== at 0x1B903A80: malloc (vg_replace_malloc.c:131) ==2222== by 0x4DD8FF: strdup (in /lib/tls/libc-2.3.3.so) ==2222== by 0x80C89FF: msDrawRasterLayerLow (mapraster.c:1305) ==2222== by 0x8077ACB: msDrawRasterLayer (mapdraw.c:1116) ==2222== by 0x8076402: msDrawLayer (mapdraw.c:754) ==2222== by 0x8075548: msDrawMap (mapdraw.c:419) ==2222== by 0x804E280: main (shp2img.c:200) ==2222== ==2222== ==2222== 80 bytes in 1 blocks are still reachable in loss record 5 of 11 ==2222== at 0x1B903A80: malloc (vg_replace_malloc.c:131) ==2222== by 0x8050F8D: msInitProjection (mapfile.c:745) ==2222== by 0x8054F91: initLayer (mapfile.c:2142) ==2222== by 0x80C89BD: msDrawRasterLayerLow (mapraster.c:1300) ==2222== by 0x8077ACB: msDrawRasterLayer (mapdraw.c:1116) ==2222== by 0x8076402: msDrawLayer (mapdraw.c:754) ==2222== by 0x8075548: msDrawMap (mapdraw.c:419) ==2222== by 0x804E280: main (shp2img.c:200) ==2222== ==2222== ==2222== 164 bytes in 1 blocks are still reachable in loss record 6 of 11 ==2222== at 0x1B903A80: malloc (vg_replace_malloc.c:131) ==2222== by 0x80AB007: initHashTable (maphash.c:71) ==2222== by 0x80551A8: initLayer (mapfile.c:2185) ==2222== by 0x80C89BD: msDrawRasterLayerLow (mapraster.c:1300) ==2222== by 0x8077ACB: msDrawRasterLayer (mapdraw.c:1116) ==2222== by 0x8076402: msDrawLayer (mapdraw.c:754) ==2222== by 0x8075548: msDrawMap (mapdraw.c:419) ==2222== by 0x804E280: main (shp2img.c:200) ==2222== ==2222== ==2222== 280 bytes in 1 blocks are still reachable in loss record 8 of 11 ==2222== at 0x1B903A80: malloc (vg_replace_malloc.c:131) ==2222== by 0x8055216: initLayer (mapfile.c:2197) ==2222== by 0x80C89BD: msDrawRasterLayerLow (mapraster.c:1300) ==2222== by 0x8077ACB: msDrawRasterLayer (mapdraw.c:1116) ==2222== by 0x8076402: msDrawLayer (mapdraw.c:754) ==2222== by 0x8075548: msDrawMap (mapdraw.c:419) ==2222== by 0x804E280: main (shp2img.c:200) ==2222== ==2222== ==2222== 524 bytes in 1 blocks are definitely lost in loss record 9 of 11 ==2222== at 0x1B903A80: malloc (vg_replace_malloc.c:131) ==2222== by 0x80C8970: msDrawRasterLayerLow (mapraster.c:1295) ==2222== by 0x8077ACB: msDrawRasterLayer (mapdraw.c:1116) ==2222== by 0x8076402: msDrawLayer (mapdraw.c:754) ==2222== by 0x8075548: msDrawMap (mapdraw.c:419) ==2222== by 0x804E280: main (shp2img.c:200) ==2222== ==2222== ==2222== 2560 bytes in 1 blocks are still reachable in loss record 10 of 11 ==2222== at 0x1B903BF7: operator new(unsigned) (vg_replace_malloc.c:133) ==2222== by 0x756FB5A: std::__default_alloc_template<true, 0>::_S_chunk_alloc(unsigned, int&) (in /usr/lib/libstdc++.so.5.0.5) ==2222== by 0x756FA6C: std::__default_alloc_template<true, 0>::_S_refill(unsigned) (in /usr/lib/libstdc++.so.5.0.5) ==2222== by 0x756F767: std::__default_alloc_template<true, 0>::allocate(unsigned) (in /usr/lib/libstdc++.so.5.0.5) ==2222== by 0x75750F7: std::string::_Rep::_S_create(unsigned, std::allocator<char> const&) (in /usr/lib/libstdc++.so.5.0.5) ==2222== by 0x7575E4E: (within /usr/lib/libstdc++.so.5.0.5) ==2222== by 0x75725A8: std::string::string(char const*, std::allocator<char> const&) (in /usr/lib/libstdc++.so.5.0.5) ==2222== by 0x1BDEDF01: __static_initialization_and_destruction_0(int, int) (/usr/include/c++/3.3.3/bits/stl_alloc.h:652) ==2222== by 0x1BDEDFC9: _GLOBAL__I__ZN3DDS9duplicateERKS_ (in /debian/home/warmerda/gdal/libgdal.so) ==2222== by 0x1BED5108: (within /debian/home/warmerda/gdal/libgdal.so) ==2222== ==2222== ==2222== 88000 bytes in 1 blocks are still reachable in loss record 11 of 11 ==2222== at 0x1B903A80: malloc (vg_replace_malloc.c:131) ==2222== by 0x8054E41: initLayer (mapfile.c:2106) ==2222== by 0x80C89BD: msDrawRasterLayerLow (mapraster.c:1300) ==2222== by 0x8077ACB: msDrawRasterLayer (mapdraw.c:1116) ==2222== by 0x8076402: msDrawLayer (mapdraw.c:754) ==2222== by 0x8075548: msDrawMap (mapdraw.c:419) ==2222== by 0x804E280: main (shp2img.c:200) ==2222== ==2222== LEAK SUMMARY: ==2222== definitely lost: 524 bytes in 1 blocks. ==2222== possibly lost: 0 bytes in 0 blocks. ==2222== still reachable: 91134 bytes in 9 blocks. ==2222== suppressed: 200 bytes in 1 blocks. So, in at least some error cases there are leaks. I will try and patch as suggested or as appropriate to correct the leaks - though to be honest fixing leaks that occur only in error cases isn't super high priority.
comment:4 by , 19 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
I have applied an approximate form of the supplied patch. I did not try and catch leak in some rare cases (ie. the old style raster drivers). All the leaks listed about were cleanuped in the case where the whole tileindex is missing.
Note:
See TracTickets
for help on using tickets.
Patch for mapraster.c resolving memory leaks