Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Mem Usage

0 views
Skip to first unread message

MG C.

unread,
Jan 10, 2002, 7:29:25 PM1/10/02
to

A question about memory usage:

Why is it that when I start up my Delphi application, the memory usage is,
say, 4,000k.

But when I minimize it, it becomes 400k

When I restore it again, it becomes 1000k, and stays around 1000k. Why did
it suddenly shrink??


So then I tried this trick:

Before my application is run (application.run), I minimize and restore it by
code (application.minimize.. application.restore). And voila, the mem usage
becomes 1000k on startup.


Of course, I want the mem usage on my app to be as small as possible. But
what's the deal with this? What's going on here?..

Anthony Richardson

unread,
Jan 10, 2002, 9:11:31 PM1/10/02
to
> Why is it that when I start up my Delphi application, the memory usage is,
> say, 4,000k.
>
> But when I minimize it, it becomes 400k
>
> When I restore it again, it becomes 1000k, and stays around 1000k. Why
did
> it suddenly shrink??

That's not related to Delphi it's a Windows thing (you should notice it with
other apps). There is an API call you can make to do the memory thing for
you without resorting to minimizing. But I can't remember what it is.

Cheers,

Anthony Richardson
Viewpoint (SA) Pty Ltd


Craig

unread,
Jan 10, 2002, 10:07:35 PM1/10/02
to
> > Why is it that when I start up my Delphi application, the memory usage
is,
> > say, 4,000k.
> >
> > But when I minimize it, it becomes 400k
> >
> > When I restore it again, it becomes 1000k, and stays around 1000k. Why
> did
> > it suddenly shrink??
>
> That's not related to Delphi it's a Windows thing (you should notice it
with
> other apps). There is an API call you can make to do the memory thing for
> you without resorting to minimizing. But I can't remember what it is.

It must be one of the secret API's that MS work tell us about...

if (!IsMSApp())
UseLotsaMemory();


Anthony Richardson

unread,
Jan 10, 2002, 10:16:09 PM1/10/02
to
Found some references:

" The effect you are seeing is something that
the OS (at least NT & W2k) is doing when any app is minimized. It is paging
the app out of memory. When you restore it, it gets paged back in, but the
extra memory used in the initialisation etc. is no longer required and hence
the reduction in size." Mark Grimmond.

" Make an API call to SetProcessWorkingSetSize (with values of -1 and -1)
when
the app is minimized. The effect of making the call is that memory reserved
by the app (but not necessarily in use) is returned to the OS." Dave
Nottage.

Anthony Richardson

unread,
Jan 10, 2002, 11:04:05 PM1/10/02
to
> " Make an API call to SetProcessWorkingSetSize (with values of -1 and -1)
> when
> the app is minimized. The effect of making the call is that memory
reserved
> by the app (but not necessarily in use) is returned to the OS." Dave
> Nottage.

Oops bad cut'n'paste, this is a clearer version.

"Make an API call to SetProcessWorkingSetSize (with values of -1 and -1).

MG C.

unread,
Jan 11, 2002, 8:55:35 AM1/11/02
to
"Anthony Richardson" <ant...@viewpointsa.com> wrote in
news:3c3e6446$1_2@dnews:

> "Make an API call to SetProcessWorkingSetSize (with values of -1 and
> -1). The effect of making the call is that memory reserved by the app
> (but not necessarily in use) is returned to the OS." Dave Nottage.

Thanks Anthony.

But is this something we should even be worried about, or bothering with?

Craig Stuntz (TeamB)

unread,
Jan 11, 2002, 11:35:29 AM1/11/02
to

MG C. wrote:

>
> But is this something we should even be worried about, or bothering with?


No. Windows will automatically reclaim memory when it needs it. The
numbers displayed in Task Manager have little direct relationship to the
actual memory hit of the application as it relates to memory required by
other apps. Look at Process->Private Bytes in NT/2000 Performance
Monitor to get a better idea.

HTH,

-Craig

--
Craig Stuntz (TeamB) · Vertex Systems Corp. · Columbus, OH
Delphi/InterBase WebLog: http://delphi.weblogs.com
InterBase PLANalyzer (Free IB optimization tool):
http://delphi.weblogs.com/IBPLANalyzer

Rudy Velthuis (TeamB)

unread,
Jan 11, 2002, 11:54:40 AM1/11/02
to
In article <Xns91935B0477FB8M...@207.105.83.65>, MG C.
says...

> But is this something we should even be worried about, or bothering with?

No, not really.
--
Rudy Velthuis (TeamB)

"There is no idea so simple and powerful that you can't get zillions
of people to misunderstand it." -- Alan Kay

Mike Williams

unread,
Jan 11, 2002, 11:49:58 AM1/11/02
to
> Why is it that when I start up my Delphi application, the memory usage is,
> say, 4,000k.
>
> But when I minimize it, it becomes 400k

Just for fun, try this same trick with the Delphi IDE. Mine was at 85 Megs
(after doing a build all with a large project group). After a minimize it
went to less than 7 Megs. As others have pointed out it's just windows
swapping memory out when the app gets minimized (the idea is you're probably
not using the app at that point). Once you bring it back and start actually
using it the memory will start going back up. Someone once wrote a Delphi
expert to call the API automatically. I'm not sure how much good that
really does for you.

-Mike


Loren Pechtel

unread,
Jan 11, 2002, 4:22:04 PM1/11/02
to
On Fri, 11 Jan 2002 13:07:35 +1000, "Craig" <cra...@bigpond.com>
wrote:

>It must be one of the secret API's that MS work tell us about...
>
>if (!IsMSApp())
> UseLotsaMemory();


You forgot to add CrashRandomly();

0 new messages