Search code examples
valgrindomnet++

How to install and use valgrind in Omnet++ IDE for memory leak detection


I have faced the problem of not freeing the memory when using my simulation because after running the simulation once or twice, the simulation hangs and the operating system needs to be restart. I want to check the entire code with the Valgrind tool or a similar tool in the Omnet++ version 6 environment to detect memory leak. The OS is Ubuntu version 22.


Solution

    1. To install Valgrind in Ubuntu use sudo apt-get install valgrind.

    2. Determine the commands used to start your simulation, for example that way.

    3. In console run your simulation under Memcheck in Valgrind using recognized commands, for example:

      $ cd /home/user/omnetpp-6.0.1/samples/tictoc/simulations
      $ valgrind --leak-check=yes ../src/tictoc -r 0 -u Cmdenv -c General -n ../src;. omnetpp.ini