something "leaks" from madGraphics.GetContributorList

delphi package - madRes, madTools, madStrings, ...

something "leaks" from madGraphics.GetContributorList

Postby ciuly » Thu Oct 24, 2013 2:45 pm

Hi,

I am working on some sort of image batch resampler app with comparisons and thought I'd give your Stretch routine a try. The app is building up on memory usage quickly after a few hundred resizes, so I took in fastmm leak detection to track it. Among other things, I noticed that something from madGraphics.GetContributorList is leaking. The stacktrace is not very helpful here though:
Code: Select all
totaling 70656 bytes, 256 pieces of

This block was allocated by thread 0xAC4, and the stack trace (return addresses) at the time was:
40485D
40A138
40A20E
A1602B [madGraphics][madGraphics][madGraphics.GetContributorList]
411CB3 [FastMM4.pas][FastMM4][FastMM4.DebugGetMem][8757]
411FE7 [FastMM4.pas][FastMM4][FastMM4.DebugAllocMem][9022]
A17722 [madGraphics][madGraphics][madGraphics.Resampling24]
4D1082 [Graphics.pas][Graphics][Graphics.TBitmap.CopyImage][7857]
75416B30 [Unknown function at GdiInitializeLanguagePack]
75416C31 [Unknown function at GetCurrentObject]
75416C9A [GetObjectW]

180 bytes, 1 piece of

This block was allocated by thread 0xAC4, and the stack trace (return addresses) at the time was:
411EDA [FastMM4.pas][FastMM4][FastMM4.DebugReallocMem][8935]
A15D8D [madGraphics][madGraphics][madGraphics.AddItem]
40482B
40A138
40A20E
A1621E [madGraphics][madGraphics][madGraphics.GetContributorList]
411CB3 [FastMM4.pas][FastMM4][FastMM4.DebugGetMem][8757]
411FE7 [FastMM4.pas][FastMM4][FastMM4.DebugAllocMem][9022]
A17722 [madGraphics][madGraphics][madGraphics.Resampling24]
4D1082 [Graphics.pas][Graphics][Graphics.TBitmap.CopyImage][7857]
75416B30 [Unknown function at GdiInitializeLanguagePack]


2244 bytes, 1 piece of

This block was allocated by thread 0xAC4, and the stack trace (return addresses) at the time was:
40485D
40A138
40A20E
A15FA0 [madGraphics][madGraphics][madGraphics.GetContributorList]
411CB3 [FastMM4.pas][FastMM4][FastMM4.DebugGetMem][8757]
411CE0 [FastMM4.pas][FastMM4][FastMM4.DebugGetMem][8777]
411FE7 [FastMM4.pas][FastMM4][FastMM4.DebugAllocMem][9022]
A17722 [madGraphics][madGraphics][madGraphics.Resampling24]
4D1082 [Graphics.pas][Graphics][Graphics.TBitmap.CopyImage][7857]
75416B30 [Unknown function at GdiInitializeLanguagePack]
75416C31 [Unknown function at GetCurrentObject]


This is happening with the latest version, downloaded today and also with some older version I had installed 2.7.4.0.

One thing to note, these are not actual leaks, or at least they are not reported when the application closes, I caught them by setting group allocations for each iteration/operation and logging those to file. In a loop, they do build up.

I didn't spend much time debugging this as I've got bigger leaks to track down but if you want me to check/test something specific, let me know.

thanks
ciuly
 
Posts: 62
Joined: Mon Apr 30, 2007 1:16 pm
Location: Romania

Re: something "leaks" from madGraphics.GetContributorList

Postby madshi » Thu Oct 24, 2013 3:01 pm

There is a "ScaleListCache" which tries to speed things up when resampling the same image dimensions multiple times. Which can happen when e.g. scaling button images etc. Such a cache obviously makes less sense if you do various stretches with all different scaling attributes. Just as a test you could disable this cache in the code to check if that fixes the "leak".

FWIW, I've been playing around with resampling algorithms quite a lot recently, for my hobby HTPC video renderer "madVR". It contains some resampling algorithms not found in madGraphics. But you can see in the lower part of madGraphics that there are some functions which are not actually used anywhere. E.g. there's a Delphi ICBI implementation, based on this:

http://www.andreagiachetti.it/icbi/

It's nice, but it's not really the best algorithm. I like Jinc with anti-ringing filter a lot (which my madVR video renderer offers). But the best upscaling algorithm available to the average programmer would be NNEDI3, I would say, although it can come with some directional (fractal like) artifacts in trees, grass etc. Also it can only do exact 2x enlargements. See here:

http://forum.doom9.org/showthread.php?t=147695

The normal "Stretch" routine in madGraphics can't really compete with any of the above, although it does do simple Lanczos, Spline etc resampling.
madshi
Site Admin
 
Posts: 9376
Joined: Sun Mar 21, 2004 5:25 pm

Re: something "leaks" from madGraphics.GetContributorList

Postby ciuly » Thu Oct 24, 2013 3:17 pm

I will disable that cache and report back.

and thanks for those 2 links. Looks interesting. Will give both ideas a try as well and will let you know my findings.
ciuly
 
Posts: 62
Joined: Mon Apr 30, 2007 1:16 pm
Location: Romania


Return to madBasic

Who is online

Users browsing this forum: No registered users and 1 guest