How do i debug Memory leaks

First time I'm seeing a memory. It looks like my FreeMem() function delete(void*) is the problem ? would that be correct
14 Replies
the magic guy
the magic guy2y ago
Just give up jk valgrind tells you where the leak occurs, not where it originates from You kinda just gotta read your code, and make sure theres a delete for every new
Revan
Revan2y ago
thats the only way memory leaks can occur right? if i just don't delete for every new?
the magic guy
the magic guy2y ago
pretty much valgrind also catches some other things, like not properly initializing a var before using it and stuff
Revan
Revan2y ago
if i see 13 errors in context 1 of 2 and 2 of 2 does that mean theres two instances where i didn't delete? or is there 13 times that i didn't delete? @themagicguy thanks for the help i found my memory leak
yamit058
yamit0582y ago
Hello everyone, I am also getting same error, Can you tell where the leak is ?
sigma
sigma2y ago
Only you are supposed to notice where the memory leak is If you are compiling in matrix, try to compile with the -g option Valgrind will use debugging information included in the executable to pinpoint more exactly where the leak is
yamit058
yamit0582y ago
Can you send the whole compile code of matrix?
sigma
sigma2y ago
What do you mean exactly by "whole compile code of matrix"?
yamit058
yamit0582y ago
The one with -g I didn't get that
the magic guy
the magic guy2y ago
Compile it your self lol
sigma
sigma2y ago
You can compile it... Aren't you using g++ command to compile?
yamit058
yamit0582y ago
Yes, but I'm not able to find the memory leak problem
the magic guy
the magic guy2y ago
Look harder? Idk what else to say
sigma
sigma2y ago
Yeah, you just have to read carefully your source code. There's no other solution to this