ReDim has performance issues.

July 7, 2006

Any of today vb programmer knows how to dynamically increase or decrease a array size. In vb its damn simple, Redim it.

Redim and Preserve looks cool but has performace issues. A ReDim actually creates a new array and copies the old contents to it to Preserve it. This happens seamlessly in vb and vb .net, until you have some kind of performance monitering tool.

Take a look for yourself by ReDim’ing a array up till 5000 elements one by one.

Solution to the problem is using System.Collections.ArrayList and do the simple add() operation.



Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: