Page 1 of 1

Memory increasing when using enumerating processes

Posted: Mon Oct 20, 2008 4:40 pm
by nildo
Hello,

I'm using MadKernel for enumerating all processes. This are the steps:

1 - Ennumerate them
2 - Open a process
3 - Enumerate them
4 - Close a process
5 - Enumerate them

When my program is on step 1, it's memory is X. But when it's on step 5, it's memory is X+Y. So it keep increasing, aways.

Here's a leak detection result that I aways get:

Code: Select all

045162FC  BlockSize: 136 Class: TIProcesses
    ST: 0050A5B1 [madKernel] [Processes] []
    ST: 0054DE03 [uClassMemoryProtection] [TMemProtectionThread.Execute] [66]
    ST: 004377FD [Classes] [ThreadProc] [9372]
    ST: 004042FA [System] [ThreadWrapper] [11565]
    ST: 7C80B683 [] [Unknown function at GetModuleFileNameA] []

0725C658  BlockSize: 26 GETMEM
    ST: 00509E7F [madKernel] [TIProcesses.RefreshItems] []
    ST: 005097E9 [madKernel] [TIProcesses.Create] []
    ST: 0050A5B1 [madKernel] [Processes] []
    ST: 0054DE03 [uClassMemoryProtection] [TMemProtectionThread.Execute] [66]
    ST: 004377FD [Classes] [ThreadProc] [9372]
    ST: 004042FA [System] [ThreadWrapper] [11565]
    ST: 7C80B683 [] [Unknown function at GetModuleFileNameA] []

0725F42C  BlockSize: 120 DynArray: Ref: 1 Len: 7
    ST: 00405A1E [System] [@DynArraySetLength] [16117]
    ST: 004F0331 [madBasic] [TICustomBasicList.AddItem] []
    ST: 00509B10 [madKernel] [RefreshItem] []
    ST: 00509E7F [madKernel] [TIProcesses.RefreshItems] []
    ST: 005097E9 [madKernel] [TIProcesses.Create] []
    ST: 0050A5B1 [madKernel] [Processes] []
    ST: 0054DE03 [uClassMemoryProtection] [TMemProtectionThread.Execute] [66]
    ST: 004377FD [Classes] [ThreadProc] [9372]
    ST: 004042FA [System] [ThreadWrapper] [11565]
    ST: 7C80B683 [] [Unknown function at GetModuleFileNameA] []

0725FB68  BlockSize: 224 Class: TIProcess
    ST: 004F4C58 [madKernel] [AddKernelObj] []
    ST: 00509ABE [madKernel] [RefreshItem] []
    ST: 00509E7F [madKernel] [TIProcesses.RefreshItems] []
    ST: 005097E9 [madKernel] [TIProcesses.Create] []
    ST: 0050A5B1 [madKernel] [Processes] []
    ST: 0054DE03 [uClassMemoryProtection] [TMemProtectionThread.Execute] [66]
    ST: 004377FD [Classes] [ThreadProc] [9372]
    ST: 004042FA [System] [ThreadWrapper] [11565]
    ST: 7C80B683 [] [Unknown function at GetModuleFileNameA] []

07260658  BlockSize: 84 Class: TICriticalSection
    ST: 00509754 [madKernel] [TIProcesses.Create] []
    ST: 0050A5B1 [madKernel] [Processes] []
    ST: 0054DE03 [uClassMemoryProtection] [TMemProtectionThread.Execute] [66]
    ST: 004377FD [Classes] [ThreadProc] [9372]
    ST: 004042FA [System] [ThreadWrapper] [11565]
    ST: 7C80B683 [] [Unknown function at GetModuleFileNameA] []

07267618  BlockSize: 24 DynArray: Ref: 1 Len: 1
    ST: 004F0331 [madBasic] [TICustomBasicList.AddItem] []
    ST: 00509B10 [madKernel] [RefreshItem] []
    ST: 00509E7F [madKernel] [TIProcesses.RefreshItems] []
    ST: 005097E9 [madKernel] [TIProcesses.Create] []
    ST: 0050A5B1 [madKernel] [Processes] []
    ST: 0054DE03 [uClassMemoryProtection] [TMemProtectionThread.Execute] [66]
    ST: 004377FD [Classes] [ThreadProc] [9372]
    ST: 004042FA [System] [ThreadWrapper] [11565]
    ST: 7C80B683 [] [Unknown function at GetModuleFileNameA] []

0726A8DC  BlockSize: 224 DynArray: Ref: 1 Len: 54
    ST: 00405A1E [System] [@DynArraySetLength] [16117]
    ST: 004EF846 [madBasic] [TIList.Grow] []
    ST: 004F02EC [madBasic] [TICustomBasicList.AddItem] []
    ST: 00509B10 [madKernel] [RefreshItem] []
    ST: 00509E7F [madKernel] [TIProcesses.RefreshItems] []
    ST: 005097E9 [madKernel] [TIProcesses.Create] []
    ST: 0050A5B1 [madKernel] [Processes] []
    ST: 0054DE03 [uClassMemoryProtection] [TMemProtectionThread.Execute] [66]
    ST: 004377FD [Classes] [ThreadProc] [9372]
    ST: 004042FA [System] [ThreadWrapper] [11565]
As you can see, it aways has something to do with MadKernel functions. Then I'm geting this leak. Is there any way for releasing all memory used by madKernel after enumerating processes?

Thanks

Posted: Thu Oct 23, 2008 1:13 am
by iconic
Why not enumerate all the processes without madKernel? After all, using madKernel for this seems like overkill.

--Iconic

Posted: Tue Oct 28, 2008 8:38 am
by madshi
Process enumeration in NT4 works differently than in any other OS, so enumerating processes with madKernel does make some sense if you need to support NT4. Also of course it's much more comfortable with madKernel than doing it manually.

Anyway, about the memory leak: @nildo, at what time do you measure the memory leaks? Also do you store the enumeration interface instances in some global variables? Is the enumeration code in some function or is it directly in the "initialization" section of a unit or in the "begin .. end" part of your project file?

Posted: Sat Dec 20, 2008 2:20 pm
by nildo
madshi wrote:Process enumeration in NT4 works differently than in any other OS, so enumerating processes with madKernel does make some sense if you need to support NT4. Also of course it's much more comfortable with madKernel than doing it manually.

Anyway, about the memory leak: @nildo, at what time do you measure the memory leaks? Also do you store the enumeration interface instances in some global variables? Is the enumeration code in some function or is it directly in the "initialization" section of a unit or in the "begin .. end" part of your project file?
For some reason I didn't get the reply notify in my e-mail. Anyway, you can put the code inside a button click and the results will be reproduced. I stoped working on this bug but you might be interested in knowing that this happens!

Thanks for your attention

Posted: Tue Feb 10, 2009 10:47 pm
by madshi
Sorry for the late reply!

Can you give me a test function which reproduces this problem? Thanks a bunch!

Posted: Wed Feb 11, 2009 11:24 am
by nildo
madshi wrote:Sorry for the late reply!

Can you give me a test function which reproduces this problem? Thanks a bunch!
Sorry! I think this was something wrong I did. Somehow I can't reproduce the code anymore

Posted: Wed Feb 11, 2009 11:31 am
by madshi
That's good for me... :D