Memory increasing when using enumerating processes

delphi package - easy access to kernel objects etc.

Memory increasing when using enumerating processes

Postby nildo » Mon Oct 20, 2008 4:40 pm

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
nildo
 
Posts: 249
Joined: Mon Mar 22, 2004 11:32 am

Postby iconic » Thu Oct 23, 2008 1:13 am

Why not enumerate all the processes without madKernel? After all, using madKernel for this seems like overkill.

--Iconic
iconic
 
Posts: 811
Joined: Wed Jun 08, 2005 5:08 am

Postby madshi » Tue Oct 28, 2008 8:38 am

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?
madshi
Site Admin
 
Posts: 9477
Joined: Sun Mar 21, 2004 5:25 pm

Postby nildo » Sat Dec 20, 2008 2:20 pm

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
nildo
 
Posts: 249
Joined: Mon Mar 22, 2004 11:32 am

Postby madshi » Tue Feb 10, 2009 10:47 pm

Sorry for the late reply!

Can you give me a test function which reproduces this problem? Thanks a bunch!
madshi
Site Admin
 
Posts: 9477
Joined: Sun Mar 21, 2004 5:25 pm

Postby nildo » Wed Feb 11, 2009 11:24 am

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
nildo
 
Posts: 249
Joined: Mon Mar 22, 2004 11:32 am

Postby madshi » Wed Feb 11, 2009 11:31 am

That's good for me... :D
madshi
Site Admin
 
Posts: 9477
Joined: Sun Mar 21, 2004 5:25 pm


Return to madKernel

Who is online

Users browsing this forum: No registered users and 1 guest

cron