New Array[] memory allocation...

BlitzMax Forums/BlitzMax Programming/New Array[] memory allocation...

Arowx(Posted 2010) [#1]
Not sure why but bear with me I'm trying to hunt down a wieird memory allocation error and would like to compare array based memory allocation with malloc and MemAlloc...

In effect I think I only need to call...

Local mem:Byte Ptr = New Byte[size]


Is that right?


ImaginaryHuman(Posted 2010) [#2]
Looks right to me, so longs as its a 1 dimensional array.

Usually you refer to the `name` of the array ie
local mem:Byte[size]

does the same thing. Then mem is an array pointer, but I think you can also use it like a byte pointer.


Arowx(Posted 2010) [#3]
What I'm trying to do is create an equivalent to ...

Local mem:Byte Ptr = MemAlloc(size)


To help track down the Windows Exception error I get on occasion?


grable(Posted 2010) [#4]
Why not just wrap MemAlloc and MemFree yourself?
Keep a list of all allocated pointers and whether they have been freed or not.

That will atleast help you figure out if your use of MemAlloc/MemFree is incorrect.


Arowx(Posted 2010) [#5]
Just trying a few back to basic approaches to the problem, it looks like the MemAlloc() function has a flaw, but I would like to try another approach to memory allocation using arrays first to help me get a better idea of when the upper memory allocation limit is reached...

http://www.blitzbasic.com/Community/posts.php?topic=88691#1008264