drmemory
(Dr. Memory) is an open-source memory profiler. A feature that is interesting for this course is detection for memory leaks. To enforce a high coding standard, your submissions will be checked for memory leaks.
drmemory
drmemory
If you are using a managed build project in Eclipse (not a Makefile project), you need to use static linking so that you can run your program outside Eclipse.
Goto "Project" -> "Properties" -> "C/C++ Build" -> "Settings" -> "Tool Settings" tab -> "MinGW C++ Linker" -> "Miscellaneous" -> type "-static" in the "Linker flags" box.
drmemory
on Windows
"Eclipse_Workspace"\"Project_Name"\Debug\"Project_Name".exe
.drmemory
. It is located at bin64
folder after extraction.drmemory
. drmemory
on macOS
drmemory
.path/to/drmemory -- path/to/your/program
For example:
/Users/kelvin/DrMemory-MacOS-2.3.0-1/bin64/drmemory -- /Users/kelvin/pa1/pa1
drmemory
on Linux
See the command for macOS. Make sure you run bin64/drmemory
(NOT bin/drmemory
!).
At the end of the output, find the result for leak(s) and possible leak(s):
~~Dr.M~~ 0 unique, 0 total, 0 byte(s) of leak(s)
~~Dr.M~~ 0 unique, 0 total, 0 byte(s) of possible leak(s)
If the number of bytes for both are 0, then your code is free from memory leaks. If the number of bytes are not zero, then your code is prone to memory leaks. Note: You can ignore the bytes for still-reachable allocation(s). They are not counted as memory leaks.