© J.C. Kessels 2009
MyDefrag Forum
June 19, 2013, 05:05:43 pm
Welcome,
Guest
. Please
login
or
register
.
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
News
:
Home
Help
Search
Login
Register
MyDefrag Forum
>
JkDefrag v3 Forum
>
Programming with the library
>
Eliminating a memory leak...
Pages: [
1
]
« previous
next »
Print
Author
Topic: Eliminating a memory leak... (Read 5390 times)
jaben
JkDefrag Junior
Posts: 7
Eliminating a memory leak...
«
on:
October 08, 2007, 04:24:07 pm »
I am trying to do some HDD analysis with the LIB/DLL. I have reduced my code to the simplest possible and I am still seeing a memory leak. Is there something I am missing?
int main(int c, char *v[])
{
c;v; // prevent warning
RunJkDefrag("c:", 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
}
It appears to be lots of directory name strings (or files) that are leaking out...
Logged
-jaben
jeroen
Administrator
JkDefrag Hero
Posts: 7156
Re: Eliminating a memory leak...
«
Reply #1 on:
October 08, 2007, 05:56:52 pm »
Thanks for reporting this, I appreciate it. I don't have time to look at this problem, so I have put it on the list with a low priority to look at it in the future. If you have any extra information then please post it in this thread!
Logged
jaben
JkDefrag Junior
Posts: 7
Paths
«
Reply #2 on:
October 08, 2007, 06:58:06 pm »
It appears that the Item->LongPath and Item->ShortPath that are built in the ConstructFullPath function (the ones below not for Inode == 5) are never being deallocated. This is all in the ScanNtfs.cpp file.
I will post more info when I find more...
Logged
-jaben
jaben
JkDefrag Junior
Posts: 7
Eliminating a memory leak...
«
Reply #3 on:
October 08, 2007, 10:38:34 pm »
ConstructFullPath is called more than once on some nodes and when they are called the second time the memory from the first time is 'lost' when the new memory is allocated on the same pointer.
I am not sure why this function is called more than once on a given node. It could be related to the calling it on a parent node, but I am not sure yet...
I have added a little code to ConstructFullPath to not allocate a new path if the node (Top pointer in the function) already has a ShortPath or a LongPath to not generate a new one. It appears to be working fine (not sure how to fully test this... and it has stopped the memory leaking.
Logged
-jaben
Lecter
JkDefrag Supporter
Posts: 11
Eliminating a memory leak...
«
Reply #4 on:
October 22, 2007, 03:41:07 am »
Sorry I cant follow you without seeing any code sample for the bug.
That program is it some kind of rudimentary GUI you wanted to make?
Logged
jaben
JkDefrag Junior
Posts: 7
Eliminating a memory leak...
«
Reply #5 on:
October 23, 2007, 11:14:28 pm »
what I wrote that calls the DLL is not at all important.
if you run this from VC+++'05 you get a memory leak.
RunJkDefrag("c:", 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
In the DLL code (downloaded from this site) the bug is in the ConstructFullPath function.
If you change ConstructFullPath to check that the pointers that it is malloc-ing onto are NULL you will find that some are not... if you free them it's fine.
IE add this just before the malloc for ShortPath (And do the same for LongPath):
if (Item->ShortPath) {
free (Item->ShortPath);
}
Logged
-jaben
jeroen
Administrator
JkDefrag Hero
Posts: 7156
Eliminating a memory leak...
«
Reply #6 on:
October 24, 2007, 12:10:03 am »
Quote from: "jaben"
ConstructFullPath is called more than once on some nodes
Thanks for the feedback! Because of your info I have now found the bug. It will be fixed in the next version!
Logged
Pages: [
1
]
Print
« previous
next »
Jump to:
Please select a destination:
-----------------------------
MyDefrag v4 Forum
-----------------------------
=> Announcements
=> Questions and help
=> Bugs and problems
=> Requests for new features
=> Scripts, and other contributions
-----------------------------
JkDefrag v3 Forum
-----------------------------
=> Announcements
=> Questions and help
=> Bugs and problems
=> Requests for new features
=> Programming with the library
Loading...