Solved

Memory Issues

Posted on 2002-07-17
6
220 Views
Last Modified: 2010-04-04
Hi People,

I've got an annoying problem.  I have an application.  When it first opens, it uses 5,316K of memory.  If I minimize it, the app uses a more respectable 752K.  If I restore it again, it uses 1,402K (which is still fine).

I minimize the application to the system tray at start up (it's an internet usage meter), but it still opens using 5,316K of memory.  This is WAY too much for such a small exe.

Can anyone tell me how I can reduce the memory foot print of this application?

Cheers!

Stu
0
Comment
Question by:SJohnson
  • 3
  • 3
6 Comments
 
LVL 20

Accepted Solution

by:
Madshi earned 400 total points
Comment Utility
Call SetProcessWorkingSetSize(GetCurrentProcess, dword(-1), dword(-1)) during initialization of your application. This has the same effect as minimizing/restoring it.

Regards, Madshi.
0
 
LVL 1

Author Comment

by:SJohnson
Comment Utility
Hi Madshi,

I had to call it repeatedly before it would work.  Is that OK?

  SetProcessWorkingSetSize(GetCurrentProcess, dword(-1), dword(-1));
  Application.Initialize;
  SetProcessWorkingSetSize(GetCurrentProcess, dword(-1), dword(-1));
  SetProcessWorkingSetSize(GetCurrentProcess, dword(-1), dword(-1));
  Application.CreateForm(TMainForm, MainForm);
  SetProcessWorkingSetSize(GetCurrentProcess, dword(-1), dword(-1));
  Application.Run;

Cheers,

Stu
0
 
LVL 20

Expert Comment

by:Madshi
Comment Utility
I see no reason for that. What if you simply keep the last one (the one before Application.Run) and delete the others? That should basically have the same effect, I think.
0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
LVL 1

Author Comment

by:SJohnson
Comment Utility
Nope, still the same.  I'll leave it as is.  That's fine Madshi.  Fantastic actually!

Stu
0
 
LVL 20

Expert Comment

by:Madshi
Comment Utility
Don't understand it, but doesn't matter...   :-)
0
 
LVL 1

Author Comment

by:SJohnson
Comment Utility
No, it's strange.  I'll take a proper look at it tomorrow when I get a little more time.  At this point in time, it's working well and that's what counts <G>

Thanks again, Mr Brain!

Stu
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now