About   -   Contact   -   Purchase   -   Search   -   What's New

Backwards Arrays
When using arrays in PowerBuilder if possible it is best to use bound arrays. This makes sure you know what you are coding by using boundary checking and it is the fastest way to process arrays.

But we do not live in a perfect world and quite often you do not know how big an array will get. So you use the wonderful unbound arrays which dynamically allocate the memory as they go.

When you are loading the arrays PowerBuilder allocates the memory in small chunks, as you add each element it allocates a new larger memory block and copies the old memory to the new area. Which can really slow things down.

A much faster way to process the arrays is to work backwards starting with the highest array position. That way PowerBuilder will allocate all the memory it requires on the first hit and will never need to expand the array. On large arrays you can save a significant amount of processor time.


Top of Page

Legal Notice

Ken Howe 2011