Memory Issues

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
LVL 1
SJohnsonAsked:
Who is Participating?
 
MadshiConnect With a Mentor Commented:
Call SetProcessWorkingSetSize(GetCurrentProcess, dword(-1), dword(-1)) during initialization of your application. This has the same effect as minimizing/restoring it.

Regards, Madshi.
0
 
SJohnsonAuthor Commented:
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
 
MadshiCommented:
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
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

 
SJohnsonAuthor Commented:
Nope, still the same.  I'll leave it as is.  That's fine Madshi.  Fantastic actually!

Stu
0
 
MadshiCommented:
Don't understand it, but doesn't matter...   :-)
0
 
SJohnsonAuthor Commented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.