Memory usage ?

ALX

Well-known member
Joined
Nov 16, 2005
Messages
253
Location
Columbia, SC
Programming Experience
10+
I'm curious to know how much memory is allocated to each label object created on a typical form. I'm probably a little too much "OLD SCHOOL" and I tend to use resourses sparingly. I know memory is cheap & plentiful these days but i still like to keep my code as lean as possible. On one form I have graphically painted the display rather than build it with label controls in an effort to keep the footprint of this program compact as there would be over 200 labels to accomplish the same display. There would be a couple slight benefits to using labels on this form though (...clickable, etc ) and I would consider using labels depending on how severely it taxes memory.
Is there a function in vb.NET that returns the amount of free memory so that I could run a quick benchmark test... or maybe someone may know just how much memory a typical label control uses ???
Thanx in advance !
 
I am not sure myself but I can tell you that if you built your own label then you must be saving a ton of resources. Label's, even though like you said don't tax the system so much, still have a lot of built in propertys and methods that you probably don't use all the time. However; if you built your own label from the user control object or class then you probably still have the same problem, maybe not as bad though. You might start from a simple object and declare all the drawing and propertys for yourself to get to the stage of the form. Then, by the time you have done this you would have maybe spent a lot of unnessary time to save resources. Then again, your custom labels would be doing what they are strictly supposed to do. If you do accomplish a nice label and are willing to share or show it off i would like to see it myself.
 
I have used
VB.NET:
Expand Collapse Copy
My.Application.Info.WorkingSet
in VB 2005 to monitor application when adding labels at runtime and the funny things is the more labels you add the less memory per label it uses.

50 labels : 274 KB
200 labels : 909 KB
1000 labels : 1885 KB
2000 labels : 2384 KB

That's not too bad with today's computer to use 909 KB for 200 labels.

Although I don't understand how you have graphically painted your form (image added ?) and why you need so many labels? Wouldn't a datagrid be more appropriate ?
 
I have considered using a data grid, and possibly would if they could have a custom appearance. One of my main objectives with this program was to make it more interesting for the user with the use of different fonts, lots of color, and loosely spaced data. I'm trying to avoid a rigid, corporate style. I imagine most data grids to resemble a spreadsheet.... 'Pretty boring stuff for what should be a casual / fun to use program. I'd be interested to find out more about data grids and how flexible they are. Also I'm in the dark about Crystal Reports. These are topics I've only started to think about (being new to vb.NET). What would be great for me to see are a few creative examples of both.
 
Post some images of your form, I'd like to see how you laid it out. I'm finding the datagrid to be rather in-flexible (color-wise) also
 
Back
Top