|
Bugzilla – Full Text Bug Listing |
| Summary: | Memory leakage due to pointer not deleted | ||
|---|---|---|---|
| Product: | ns-3 | Reporter: | Menglei Zhang <mengleizhang.mz> |
| Component: | network | Assignee: | ns-bugs <ns-bugs> |
| Status: | RESOLVED WONTFIX | ||
| Severity: | normal | CC: | krotov, tomh |
| Priority: | P3 | ||
| Version: | ns-3.26 | ||
| Hardware: | All | ||
| OS: | All | ||
Can you provide a test case we can use to test this? We do not see memory error reports when we used valgrind on the ns-3 regression test suite. My suggestion is to use smart pointer for the newData variable, and avoid the c style code. I am not convinced there is a problem. Please provide a test program that exhibits a memory leak. newData is not leaked because it is stored in m_data member. Previous m_data is recycled if its reference counter reaches 0: https://code.nsnam.org/index.cgi/ns-3-dev/file/f868c87528b1/src/network/model/buffer.cc#l334 There is a reference counter system already in place, it is just implemented manually. C++ "smart" pointers are not used because they have additional overhead (such as synchronization to make their modification atomic) which is avoided by implementing only the required parts in C. Closing it with WONTFIX, can be reopened if the test case is provided. |
In the methods Buffer::AddAtStart and Buffer::AddAtEnd, the newData pointer, created by the following command, is not deleted and cause memory leakage. struct Buffer::Data *newData = Buffer::Create (newSize); It can be fixed by changing the newData to a member variable, or use a smart pointer.