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 guy3y 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
RevanOP3y ago
thats the only way memory leaks can occur right? if i just don't delete for every new?
the magic guy
the magic guy3y ago
pretty much valgrind also catches some other things, like not properly initializing a var before using it and stuff
Revan
RevanOP3y 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
yamit0583y ago
Hello everyone, I am also getting same error, Can you tell where the leak is ?
sigma
sigma3y 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
yamit0583y ago
Can you send the whole compile code of matrix?
sigma
sigma3y ago
What do you mean exactly by "whole compile code of matrix"?
yamit058
yamit0583y ago
The one with -g I didn't get that
the magic guy
the magic guy3y ago
Compile it your self lol
sigma
sigma3y ago
You can compile it... Aren't you using g++ command to compile?
yamit058
yamit0583y ago
Yes, but I'm not able to find the memory leak problem
the magic guy
the magic guy3y ago
Look harder? Idk what else to say
sigma
sigma3y ago
Yeah, you just have to read carefully your source code. There's no other solution to this
Want results from more Discord servers?
Add your server