Understanding output given by valgrind

Viewed 33

I am writing a Monte Carlo simulation engine, and I am experiencing what I believe to be memory leaks in my software. For example, I am running a certain calculation, and it turns out that unless I have a

std::cout <<"Some string" << std::endl;

in the region where the computation is written, my code does not work.

There must be an error/memory leak in my program if I am seeing such behavior. So, I decided to run valgrind. This how I compiled it all: g++ -std=c++14 -Wall -Wextra -Wdisabled-optimization -Werror -pedantic -Ofast -march=native -fopenmp·-g main.cpp misc.cpp classes.cpp -o cosolv_ani Then I ran it as: valgrind --leak-check=full --show-leak-kinds=all -s --log-file=valgrind.out ./cosolv_ani -f 1 -M 1 -p 4mer.txt -t geom_and_esurf.txt -u energydump.mc -e orientation.mc -s stats.mc -o coords.mc

The output is quite large. Here is the link to it: https://pastebin.mozilla.org/tcfR5b8x.

My question is, how do I even start reading valgrind? What do these terms mean? I see references to main.cpp, misc.cpp, but I do not understand how to go about this problem...

I apologize for the wall of text, but how does one go about parsing through all of this information?

I see a reference to misc.cpp: 40. This is the line:

std::map <int, std::array<double,3>> Or2Dir = { {0, {1.0,0,0}}, {1, {0,1.0,0}}, {2, {0,0,1}}, {3, {-1,0,0}}, {4, {0,-1,0}}, {5, {0,0,-1}}, {6, {1.0/(std::sqrt(2)), 1.0/(std::sqrt(2)), 0}}, {7, {1.0/(std::sqrt(2)), 0, 1.0/(std::sqrt(2))}}, {8, {1.0/(std::sqrt(2)),-1.0/(std::sqrt(2)),0}}, {9, {1.0/(std::sqrt(2)),0,-1.0/(std::sqrt(2))}}, {10, {-1.0/(std::sqrt(2)),1.0/(std::sqrt(2)),0}}, {11, {-1.0/(std::sqrt(2)),0,1.0/(std::sqrt(2))}}, {12, {-1.0/(std::sqrt(2)),-1.0/(std::sqrt(2)),0}}, {13, {-1.0/(std::sqrt(2)),0,-1.0/(std::sqrt(2))}}, {14, {0,1.0/(std::sqrt(2)),1.0/(std::sqrt(2))}}, {15, {0,1.0/(std::sqrt(2)),-1.0/(std::sqrt(2))}}, {16, {0,-1.0/(std::sqrt(2)), 1.0/(std::sqrt(2))}}, {17, {0,-1.0/(std::sqrt(2)), -1.0/(std::sqrt(2))}}, {18, {1.0/(std::sqrt(3)),1.0/(std::sqrt(3)),1.0/(std::sqrt(3))}}, {19, {1.0/(std::sqrt(3)),-1.0/(std::sqrt(3)),1.0/(std::sqrt(3))}}, {20, {1.0/(std::sqrt(3)),1.0/(std::sqrt(3)),-1.0/(std::sqrt(3))}}, {21, {1.0/(std::sqrt(3)),-1.0/(std::sqrt(3)),-1.0/(std::sqrt(3))}}, {22, {-1.0/(std::sqrt(3)),1.0/(std::sqrt(3)),1.0/(std::sqrt(3))}}, {23, {-1.0/(std::sqrt(3)),1.0/(std::sqrt(3)),-1.0/(std::sqrt(3))}}, {24, {-1.0/(std::sqrt(3)),-1.0/(std::sqrt(3)),1.0/(std::sqrt(3))}}, {25, {-1.0/(std::sqrt(3)),-1.0/(std::sqrt(3)),-1.0/(std::sqrt(3))}} };

I have made a map that assigns an integer to one of the 26 directions on a cubic lattice (diagonals included). Is there an error with initializing a map this way? The nature of my simulation requires me to call on these directions quite frequently.

0 Answers
Related