Archived

This topic is now archived and is closed to further replies.

NotTaxes

Memory Management in VB?

Recommended Posts

Hi... got a strange problem. I am using VB to create a terrain map (for a geological survey problem). I create an array to store the height-map data. The array is currently 200x200, which is pretty poxy for the end-user''s needs, and takes up around 50mb of ram (the array handles height-map data as well as texture and full geometry per square unit). The program starts up really swiftly (about six seconds) and even manages to give me a decent frame rate (around 60fps), but... as soon as I End the program it takes around 2 minutes for the application to finish unloading. Until it''s finished, there''s 100% cpu usage, which is a real pain in the neck. Anyhow, I''m just wandering if anyone knows why it is taking so long to exit, and if there''s anything I can do to speed it up some. I have plenty of talent and vision, I just don''''t give a damn.

Share this post


Link to post
Share on other sites
You just found another good reason why the pros use C++ instead VB6 for 3D engine dev. ;-)

Tim

--------------------------
glvelocity.gamedev.net
www.gamedev.net/hosted/glvelocity

Share this post


Link to post
Share on other sites
Yeah, but the client wants it in VB (they gave me the spec and when I questioned their choice they mumbled something about ''easy to maintain by our inhouse coders'').

The whole thing runs fine (and damned swiftly I might add... shocker of note since I reckoned VB would be way under-powered for the task), but it''s just ''exit-hostile''. I''m thinking I can go one of two ways: just disable the buttons and ''forget'' to put File|Exit on the menu; when they exit I reboot the machine (it''ll probably be faster anyhow).

I have plenty of talent and vision, I just don''''t give a damn.

Share this post


Link to post
Share on other sites
im asssuming ur using a dynamic array in which case it''s worth a try to manually de-allocating it by rediming it to either 1 or if VB allows you to, 0

However it sounds like your application isn''t exiting and that the proble may have nothing to do with your array (or at least the huge size of it)

Resist Windows XP''s Invasive Production Activation Technology!

Share this post


Link to post
Share on other sites
Do you use a tree control by any chance? And fill it with a ton of nodes?

There was a bug in VB6, that they finally fixed in SP6. It _was faster to dump the contents of the tree control manually rather than let VB do it prior to SP6.

There may be a similar problem with arrays... I wouldn't waste too much time on it, _every VB program that performs any significant task that I've ever used exhibits this problem.

You run NT?
Stick this in a button, and wap it a couple of time. Watch the memory allocation of VB. It never goes back down until you close...

Dim something as Object
for i = 1 to 1000000
set something = new Object
set something = nothing
next i

Magmai Kai Holmlor
- The disgruntled & disillusioned


Edited by - Magmai Kai Holmlor on June 10, 2001 8:34:19 PM

Share this post


Link to post
Share on other sites
Magmai Kai Holmlor, nah, no tree array, just a standard-issue memory array. Electro, thank for that, I will give it a go (I''ve got a clean-up that goes through each element and sets it to nothing, but it''s not any faster... redimming to 0 size may be perfect!).

I have plenty of talent and vision, I just don''''t give a damn.

Share this post


Link to post
Share on other sites
Are you sure it is actually the array which is slowing it down?

What is the array actually of, if it is UDT then what is in it?

Also, try using

Erase DynamicArray

Instead of redimming it to 0 elements. I''m not sure, but it might be faster.

Trying is the first step towards failure.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
And if all else fails, you can just lower the priority of your program to lowest before exitting, then although it will use the processor, it wont interfere with anything else as it does so.

Yes it is a hack, but it is better than nothing

Share this post


Link to post
Share on other sites