Memory Question...

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

In an effort to try curbing the amount of memory my application is using I
would like to ask a simple question...

I have multiple forms with multiple subs in them. does a Dim statement
clear itself from memory when a form closes. the reason I ask is that I have
a large amount or dim drw as datarow statements in my app and If the
application doesnt clear the contents of the dim I'd like to manually do it
at the end of each sub

Cheers
Niels
 
Diminishing a variable doesn't necessarily take up a lot of space.
Especially a DataRow since its a reference variable (8bytes I belivee).
Sure, the less the better, but with an "unlimited" heap its not that big of
a deal. It would take a LOT of variable declarations to take up a sizeable
amount of memory.

As for clearning the contents, again, its not a value type variable, so you
can set it to Nothing which will destory the reference. As soon as there
are no more references to the variable/object in question, Garbage
collection comes by and cleans it all up (not right away). Also, as soon as
it leaves the scope of the sub it will destroy that reference as well
(unless declared static within the procedure).

Instead of worring about memory consumption with your dim statements, worry
about it with your data within the dataset, thats where most consumption
comes from. (Ahh XML, something fantastic, but damn there can be a lot of
overhead)
 
Righto - Thanks for the info.

The item taking up most memory within my program is a great big image bitmap
(around 1280 x 1024 at least if not bigger! I managed to knock this down a
tiny bit by using Format16bppRgb555 but if there's a way to make the image
even smaller on memory reserves I'd love to know

Cheers

Niels
 
Yeah I have dealt with a similar problem (with much larger images). I could
spend more time with it in making it more memory efficient (perhaps using
DirectX) but don't really have the time nor care...

Bitmaps take up a massive amount of memory because it takes so many
resources to actually draw it. That was a fun lesson to learn.

-CJ
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top