C++ client 'class SessionDataSet' will memory leak
See original GitHub issue通过valgrind检测,发现这里存在一些内存泄露,会导致时间久了爆内存
==20709== 576 bytes in 8 blocks are definitely lost in loss record 47 of 49
==20709== at 0x4C3217F: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==20709== by 0x4F36B12: SessionDataSet::constructOneRow() (in /home/tan/iotdb/client-cpp-0.12.0-SNAPSHOT-cpp-linux-x86_64/lib/libiotdb_session.so)
==20709== by 0x4F3676C: SessionDataSet::hasNext() (in /home/tan/iotdb/client-cpp-0.12.0-SNAPSHOT-cpp-linux-x86_64/lib/libiotdb_session.so)
==20709== by 0x120739: query1() (in /home/tan/iotdb/client-cpp-0.12.0-SNAPSHOT-cpp-linux-x86_64/a.out)
==20709== by 0x123B51: main (in /home/tan/iotdb/client-cpp-0.12.0-SNAPSHOT-cpp-linux-x86_64/a.out)
==20709==
==20709== 1,218 (376 direct, 842 indirect) bytes in 1 blocks are definitely lost in loss record 48 of 49
==20709== at 0x4C3217F: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==20709== by 0x4F3CC71: Session::executeQueryStatement(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >) (in /home/tan/iotdb/client-cpp-0.12.0-SNAPSHOT-cpp-linux-x86_64/lib/libiotdb_session.so)
==20709== by 0x120610: query1() (in /home/tan/iotdb/client-cpp-0.12.0-SNAPSHOT-cpp-linux-x86_64/a.out)
==20709== by 0x123B51: main (in /home/tan/iotdb/client-cpp-0.12.0-SNAPSHOT-cpp-linux-x86_64/a.out)
==20709== 3,535 (376 direct, 3,159 indirect) bytes in 1 blocks are definitely lost in loss record 49 of 49
==20709== at 0x4C3217F: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==20709== by 0x4F3CC71: Session::executeQueryStatement(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >) (in /home/tan/iotdb/client-cpp-0.12.0-SNAPSHOT-cpp-linux-x86_64/lib/libiotdb_session.so)
==20709== by 0x4F3C504: Session::checkTimeseriesExists(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >) (in /home/tan/iotdb/client-cpp-0.12.0-SNAPSHOT-cpp-linux-x86_64/lib/libiotdb_session.so)
==20709== by 0x120160: createTimeseries1() (in /home/tan/iotdb/client-cpp-0.12.0-SNAPSHOT-cpp-linux-x86_64/a.out)
==20709== by 0x123B47: main (in /home/tan/iotdb/client-cpp-0.12.0-SNAPSHOT-cpp-linux-x86_64/a.out)
大概看了代码,SessionDataSet析构的时候并没有释放内存?
Issue Analytics
- State:
- Created 2 years ago
- Reactions:3
- Comments:7 (5 by maintainers)
Top Results From Across the Web
Memory leaks in C# while using C++/CLI defined class with ...
It seems, that this memory leak (or bad work of garbage collection) happens everytime I implement finalizer in C++/CLI. Why happens this memory...
Read more >Memory leak in C++ and How to avoid it? - GeeksforGeeks
The best way to avoid memory leaks in C++ is to have as few new/delete calls at the program level as possible –...
Read more >Find memory leaks with the CRT Library - Microsoft Learn
Learn how the C/C++ debugger and C Run-time Library (CRT) can help find memory leaks. The techniques include memory-leak reports and comparing memory ......
Read more >3 Troubleshoot Memory Leaks - Java - Oracle Help Center
A memory leak occurs when an application unintentionally holds references to Java objects or classes, preventing them from being garbage collected. These ...
Read more >CWE-401: Missing Release of Memory after Effective Lifetime
The software does not sufficiently track and release allocated memory after it ... The following C function leaks a block of allocated memory...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@jixuan1989 Thanks for your C++ work, C++ is so complicated so I just wait your team to fix. besides, there is another place causes memory leak(class SessionDataSet), this is a way to fix it, by adding one line to class SessionDataSet :
After checking the SessionDataSet, this issue can be closed.
@jixuan1989 Thanks. I have created JIRA IOTDB-1282 for this.