[.net] vb.net Redim Preserve Efficientcy?
how efficient is it to redim preserve to free up memory in an array compared to just letting the item waste memory?
anybody have any tips?
I presume you're trying to grow an array that turned out to be too small for your needs. Arrays are meant to be fixed in size, don't let VB fool you. If you need a growable array, use an ArrayList or any of the other System.Collections.
I suppose it depends on the number of array elements and the memory consumption of each element.
well the majority of the time the array is fixed, but periodicaly i need to add or remove a ship.
---------------------------------------------------
Square Dance Studios
---------------------------------------------------
Square Dance Studios
Don't Redim each time you add a ship, Redim a big chunk like 100 more than you need, then when you fill that array Redim it to be 100 larger. This will work a lot faster.
Quote:Original post by Stru
Don't Redim each time you add a ship, Redim a big chunk like 100 more than you need, then when you fill that array Redim it to be 100 larger. This will work a lot faster.
Or better yet, use System.Collections.ArrayList, since it will already do that for you.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement