Solved

Memory Issues

Posted on 2002-07-17
6
221 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
ID: 7159248
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
ID: 7159347
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
ID: 7159367
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 1

Author Comment

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

Stu
0
 
LVL 20

Expert Comment

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

Author Comment

by:SJohnson
ID: 7159488
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

867 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