RAM usage

John Cassell

Well-known member
Joined
Mar 20, 2007
Messages
65
Programming Experience
Beginner
Hi There,

I am developing an application which is about 50% complete. I thought it would be worth checking to see how much RAM it was hogging because some of my users will not have as good a hardware spec as my machine. I ran it to find that it was using 25MB right from when it opens. I thought this was a lot compared to how simple the first form is.

Is there any advice to make my app as lightweight as possible with regards to RAM?

Thanks

John
 
Ignore that!!

This question has come up time and time again....the app will gulp up as much memory as it can see free, and then use something called a Garbage Collector to free up the RAM, on a timed basis. You can call this yourself, but really no point!

I assume you are looking at Task Manager? The Mem Usage column is very inaccurate, it's better (I was told) to add teh VM Size column as this is how much memory the process really is actually using.

When my app opens, I'm at about 15mb. As soon as I open the search form, I shoot up to 40Mb (mem usage), but VM size reports only 27mb.

To be honest, I personally wouldn't worry about the mem usage too much :)
 
That's correct, those are allocations and wishful "thinking" from the runtime memory management. Minimize the app and task manager reports a more conservative allocation number closer to real usage, probably 1-2MB.
 
Hi Arg/John,

Yes I am using Task Manager and the VM column does report a lot less usage. I am happy to take your word for it and not worry anymore about the mem usage.

Yes, minimizing the app shrunk the size enormously less than 1mb so these are all good tips I am picking up!

Cheers

John
 
I am happy to take your word for it and not worry anymore about the mem usage.
You don't have to worry, but you do have to care...
Controls
Generally many controls will take more memory, if you've noticed the clean professional look of many applications it's because they don't expose many controls at once and organize UI well.
Data
Also consider the loaded data, much data results in high mem usage, especially for database lookups a common problem is to load and display everything when user may only be in search of a selection, or paging etc.
Coding
Remember to dispose all objects created and finished with in code. In some cases one also may need to clear arrays/collections while processing, or manage graphics resources economically for example. Shared variables should be avoided. Look out for class level declarations, the narrower scope the better memory management (and also better Object Oriented Programming).

well, this was just some quick thoughts around the topic :)
 
Hi John,

Thanks for the info, to be honest I do have some controls displaying information which probably isn't necessary so I'll take care in future not to be wasteful on the RAM front.

Cheers

John
 
Back
Top