PDA

View Full Version : memory question



seiferalmasy
13-02-2007, 01:17 PM
Well, here I am again. My application memory goes as high as 20000K physical.

So is this normal and if so, is it wise to use trimworkset and swap the memory out?

How do you guys deal with high mem?

AthenaOfDelphi
13-02-2007, 02:12 PM
Hi seiferalmasy,

To answer you're 'is it normal question'... that depends on what your application is doing. The web server software I built for the on-line game I run regularly breaks the 500MB barrier (The highest I've seen it use is around 750MB) on physical memory because it caches the compiled scripts that generate the pages and theres a lot of pages with some very big scripts.

Whether its normal for your application will depend on what it is you're loading into memory.... if you're loading say 15MB of content, then the answer is probably yes, its normal and given most machines these days have bags of memory its not really anything to worry about (Delphi 5 sitting with no projects/files open is at this very moment chewing it way through 10MB of memory). But if you're only loading 2MB of content and the apps usage is growing steadly as its running, then its possible you have a memory leak which will of course need to be addressed.

seiferalmasy
13-02-2007, 02:15 PM
hmm, well i have one 500*600 picture and then one 425*425 picture overlapping.

This could possibly create 20000K?

If it is nothing to worry abut then cool. Out of curiosity, what happens if there is 5 MB of free memory and my app comes along trying to dump 20000 into mem? Does the difference get swapped out or does the app simply not load?

I wouldn't know, I have bags of memory ;)

AthenaOfDelphi
13-02-2007, 02:22 PM
If we assume the images are using 4 bytes per pixel, and assume there is no other baggage with them, then they equate to approx. 1.9MB.

I did once test what happens when you run out of physical memory and basically my app started to use swap space. But based on the fact that you only have two images approximately 1.9MB, then I'd say you have a serious memory allocation problem.

Is it possible to send me the source and exe?

seiferalmasy
13-02-2007, 02:24 PM
At the moment no, but I can probbaly prepare a demo for you. the bare bones of it. But to be honest, all I am doing is using stretchdraw for 2 images inside a dxtimer and drawing them to screen.

But I shall prepare a demo:)

it hits 18000 with just 1 500*600 image loaded (the logo page at startup)

exe size 2.85MB

edit:

bugger that too, with 0 image loaded it still hits 18000 just from opening. Def sommert wrong. will send demo as soon as i can

AthenaOfDelphi
13-02-2007, 02:36 PM
I think a quote from Mr. Simpson is in order actually.... DOH!

The physical memory used by your app could include many other things.... I've just loaded my map editor from last years competition... the EXE itself is about 1.5MB, but when it runs, it uses around 6.5MB... it uses unDelphiX so it will load DirectX DLL's (I'm assuming) and other stuff.

So say 2.5MB for your app, 1.9MB of content, what looks to be around 5MB (minimum) of baggage from unDelphiX and its up to nearly 10MB without breaking a sweat. Throw into that your surface buffers and yes, it could quite easily use 20MB.

So, like I said... I think a big fat DOH! is required on my part :-)

The key thing if you've got concerns is to monitor usage over time... if you notice it gradually increasing, then thats a good indicator of a memory leak. Otherwise, I wouldn't worry too much about it.

seiferalmasy
13-02-2007, 02:37 PM
cheers:)