Giter Club home page Giter Club logo

memorymanager's Introduction

Memory Manager

This is a pretty basic memory manager, which checks for memory leaks in a c++ programm. To use it, it must be inluded in the c++ project and the it must be compiled with de debug flag, no includes are needed.

Memory Statistics

It will then colled statistics during the execution of the program and print statistics at the end. It will discover wrong deletes, leaked memory, the amount of leaked memory and total used memory.
Example:

----------------------------------------
Memory Statistics
----------------------------------------

#  operator     size address     memory 
----------------------------------------
1  new[]         100 0x100103b80    100
2  new             4 0x100103c30    104
3  new[]         400 0x100103c80    504
4  new             8 0x100103e50    512
5  new[]         800 0x100103ea0   1312
6  new[]        2408 0x100803200   3720
7  delete          8 0x100103b80   3620 *** wrong delete ***
8  delete          8 0x100103e50   3612
9  delete[]        8 0x100103ea0   2812
10 delete[]        8 0x100103c80   2412

Memory Leaks
----------------------------------------
2  new             4 0x100103c30      4
6  new[]        2408 0x100803200   2412

Memory Usage
----------------------------------------
No. of leaks:        2
Max used memory:     3720
Leaked memory:       2412

Line Numbers

When a leak is detected, it would be helpfull to get the line number, where the memory was allocated. To get the line numbers, the header MemMngr.h must be included in the according file. It will then print the file name and line number, where the memory which was not deallocated, was allocated.
Example:

----------------------------------------
Memory Statistics
----------------------------------------

#  operator     size address     memory 
----------------------------------------
1  new[]         100 0x100103b80    100
2  new             4 0x100103c30    104
3  new[]         400 0x100103c80    504
4  new             8 0x100103e50    512
5  new[]         800 0x100103ea0   1312
6  new[]        2408 0x100803200   3720
7  delete          8 0x100103b80   3620 *** wrong delete *** /Users/robin/Development/Xcode/MemoryManager/MemoryManager/main.cpp:32
8  delete          8 0x100103e50   3612
9  delete[]        8 0x100103ea0   2812
10 delete[]        8 0x100103c80   2412

Memory Leaks
----------------------------------------
2  new             4 0x100103c30      4 /Users/robin/Development/Xcode/MemoryManager/MemoryManager/main.cpp:24
6  new[]        2408 0x100803200   2412 /Users/robin/Development/Xcode/MemoryManager/MemoryManager/main.cpp:29

Memory Usage
----------------------------------------
No. of leaks:        2
Max used memory:     3720
Leaked memory:       2412

memorymanager's People

Contributors

robinwyss avatar

Watchers

 avatar  avatar

Forkers

ratalaika reiisky

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.