bar
2008-03-29 19:39:53 UTC
Hello all
My program uses
CPU 1% and Memory 10-15 MB intially.
Program still running, after 10-15 hours the CPU usage by the program is
98%. Is there any tool to detect the memory leak, i am using BCB6.
Still i didn't mention about what the program is doing, but i have couple of
questions
1.Why the memory leak or CPU usage increases.
2.If have some loop like
sample code:
for(int a=IndexOfNewsItem; a<TotalMenuItems; a++)
{
int IndexOfSubItem = NMainitem->ChildNodes->IndexOf("subitem");
if(IndexOfSubItem != -1) //No subitem found
{
int TotalMainItems = NMainitem->ChildNodes->Count;
int TotalSubItems = TotalMainItems - IndexOfSubItem;
NoOfSubItems = NoOfSubItems + TotalSubItems;
}
}
I have 4 interger variables. This loops fires may times when the program
runs.
Does it make any difference, if i move these variables in a class so that
they are declared once.
3.When multiple declarations like here are happening, what will happen to
the previous variables memory.
Any ideas greatly appreciated.
Thanks
SA
My program uses
CPU 1% and Memory 10-15 MB intially.
Program still running, after 10-15 hours the CPU usage by the program is
98%. Is there any tool to detect the memory leak, i am using BCB6.
Still i didn't mention about what the program is doing, but i have couple of
questions
1.Why the memory leak or CPU usage increases.
2.If have some loop like
sample code:
for(int a=IndexOfNewsItem; a<TotalMenuItems; a++)
{
int IndexOfSubItem = NMainitem->ChildNodes->IndexOf("subitem");
if(IndexOfSubItem != -1) //No subitem found
{
int TotalMainItems = NMainitem->ChildNodes->Count;
int TotalSubItems = TotalMainItems - IndexOfSubItem;
NoOfSubItems = NoOfSubItems + TotalSubItems;
}
}
I have 4 interger variables. This loops fires may times when the program
runs.
Does it make any difference, if i move these variables in a class so that
they are declared once.
3.When multiple declarations like here are happening, what will happen to
the previous variables memory.
Any ideas greatly appreciated.
Thanks
SA