Home > Software engineering >  MFC CMapStringToPtr in class, don't release will cause memory leaks after use
MFC CMapStringToPtr in class, don't release will cause memory leaks after use

Time:11-12

In the process of program testing, memory leaks are detected, through valgrind positioning, found is CMapStringToPtr SetAt when using the memory leaks, he seems to call at the bottom of the cstrings, is excuse me who knows to CMapStringToPtr. The SetAt underlying principle or code, or a solution to a memory leak, thank you, below is valgtind logs,

==20058==290 bytes in 20 blocks are definitely lost in loss record 1 of 1
====20058 at 0 x40288f6: operator new [] (unsigned int) (357) vg_replace_malloc. C:
====20058 by 0 x804c46f: cstrings: : AllocBuffer (int) (in/root/valgrind/SsiMemoryTest. Exe)
====20058 by 0 x804c753: cstrings: : AllocBeforeWrite (int) (in/root/valgrind/SsiMemoryTest. Exe)
====20058 by 0 x804c89d: cstrings: : AssignCopy (int, char * const) (in/root/valgrind/SsiMemoryTest. Exe)
====20058 by 0 x804ca7a: cstrings: : operator=(char const *) (in/root/valgrind/SsiMemoryTest. Exe)
====20058 by 0 x804ae6c: CMapStringToPtr: : SetAt (char const *, void *) (in/root/valgrind/SsiMemoryTest. Exe)
====20058 by 0 x8049440: main (SsiMemoryTest. CPP: 25)

CodePudding user response:

https://www.cnblogs.com/jiangzhaowei/p/4972239.html
  • Related