Awesome Open Source
Awesome Open Source

MCheck

MCheck is a lightweight memory sanitizer similar to Valgrind. MCheck records heap memory consumption of an executable without needing to recompile by intercepting library calls to new and delete implemented in libstdc++.

screenshot

Compatibility

  1. Designed to run on Linux operating systems (tested on Ubuntu 18.0.4) using the C++17 standard
  2. Untested on MacOS, but may work properly due to POSIX compliance
  3. Does not support Windows, and will not run properly due to lack of POSIX compliance

Setup

  1. Clone the git repository
git clone [email protected]:DavidPeet8/Memory-Sanitizer.git
  1. Change working directory to project root directory and run make
cd <project root> && make
  1. Run the sanitizer on an executable via mcheck <exe to check path>

Details

MCheck Flags:

  • -v option indicates to use verbose realtime logging

Capabilities & Limitations:

  • Provides detailed information on the history of a processes memory consumption, including order, size, and base address of all allocations and deallocations
  • Due to lightweight implementation, line numbers and code snippets cannot be provided for detected memory leaks
  • Currently cannot detect leaks in C style memory management or any memory allocation system calls

Troubleshooting

  1. Check that the created shared objects libmcheck.so and libmcheckstorage.so have been installed into ~/mylibs
  2. Check that mcheck has been added to your $PATH environment variable
  3. If you are running mcheck in a context where DLL's must be installed at the system level (for example trying to profile with perf) run the following:
sudo mkdir /usr/lib/mcheck
sudo cp ~/mylibs/* .
sudo echo "/usr/lib/mcheck" >> /etc/ld.so.conf.d/.conf
sudo ldconfig  

Future Improvements

  • Allow for the data collector to persist the allocation timeline to a swap file if the time line begins to hog memory as this may cause memory thrashing / constant state of paging
  • Allow for additional options to be passed via POSIX message queue
  • Shim C style memory mangement methods (malloc, calloc, realloc, free, etc)
  • Look into possible ways of tracking / overloading memory allocation system calls (mmap, brk, etc)

Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
C Plus Plus (371,647) 
Makefile (23,625) 
Linux (16,570) 
Cpp (15,970) 
Posix (533) 
Dll (463) 
System Programming (149) 
Memory Allocation (135) 
Related Projects
Advertising 📦 9
All Projects
Application Programming Interfaces 📦 120
Applications 📦 181
Artificial Intelligence 📦 72
Blockchain 📦 70
Build Tools 📦 111
Cloud Computing 📦 79
Code Quality 📦 28
Collaboration 📦 30
Command Line Interface 📦 48
Community 📦 81
Companies 📦 60
Compilers 📦 60
Computer Science 📦 74
Configuration Management 📦 39
Content Management 📦 167
Control Flow 📦 197
Data Formats 📦 77
Data Processing 📦 266
Data Storage 📦 132
Economics 📦 60
Frameworks 📦 198
Games 📦 122
Graphics 📦 103
Hardware 📦 148
Integrated Development Environments 📦 47
Learning Resources 📦 147
Legal 📦 28
Libraries 📦 119
Lists Of Projects 📦 21
Machine Learning 📦 336
Mapping 📦 61
Marketing 📦 15
Mathematics 📦 55
Media 📦 228
Messaging 📦 97
Networking 📦 304
Operating Systems 📦 84
Operations 📦 120
Package Managers 📦 52
Programming Languages 📦 229
Runtime Environments 📦 96
Science 📦 42
Security 📦 375
Social Media 📦 26
Software Architecture 📦 70
Software Development 📦 68
Software Performance 📦 57
Software Quality 📦 127
Text Editors 📦 45
Text Processing 📦 131
User Interface 📦 310
User Interface Components 📦 465
Version Control 📦 29
Virtualization 📦 68
Web Browsers 📦 38
Web Servers 📦 25
Web User Interface 📦 194