Opened 19 years ago
Closed 18 years ago
#1476 closed defect (fixed)
Usage of different heaps causes memory leak with SWIG C# on Win32
Reported by: | szekerest | Owned by: | szekerest |
---|---|---|---|
Priority: | normal | Milestone: | 4.8 release |
Component: | MapScript-SWIG | Version: | 4.6 |
Severity: | major | Keywords: | |
Cc: |
Description
Calling mapObj.GetProjection() causes unexpected break using the debug build of SWIG mapscript with C#. The reason of the problem is that the returned string allocated in libmap.dll and freed in mapscript.dll using different heaps with CRT. The resulting behavious is that the returning string will not be freed at all. This issue applies to all off the functions passing memory blocks using this way. This problem could be resolved by replacing free() to msFree() in CSharp_mapObj_getProjection, but a more general soution would be expected.
Change History (8)
comment:2 by , 19 years ago
Sean, Frank suggested to compile libmap.dll and mapscript.dll to link CRT dynamically (/MD) which finally worked for me. However compiling either of them using CRT statically will not work, because the dll's will use separate heap. In general the following condirions should be met: 1. CRT is used with dll /MD (not statically linked) 2. Both of the modules use the same version (eg. msvcrt.dll or msvcr71.dll), suggested to compile with the same compiler version. VS 6.0 will link to msvcrt.dll, VS.NET will linkt to msvcr71.dll by default. So the makefile of mapscript might be modified accordingly. I recommended to consider using malloc and free in the same module if so the statements above will fall out of scope. Tamas
comment:4 by , 18 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
Solution is to always use the same CRT. Tamas agrees.
comment:5 by , 18 years ago
Keywords: | VERIFIED added |
---|---|
Milestone: | FUTURE → 4.8 release |
Severity: | minor → major |
Reopening since at least MS-CVS, MS-4-8, hobu's buildkit and ms4w suffers from this problem.
comment:6 by , 18 years ago
Keywords: | VERIFIED removed |
---|---|
Resolution: | wontfix |
Status: | closed → reopened |
NC
comment:7 by , 18 years ago
Owner: | changed from | to
---|---|
Status: | reopened → new |
Reassigned to Tamas Szekeres
comment:8 by , 18 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Changed csharp/makefile.vc to use the OPTFLAGS from nmake.opt, ensuring to compile libmap.dll and mapscript.dll with the same options.
Note:
See TracTickets
for help on using tickets.