Limit on size of System.Alloc

Discussion about the ZBasic language including the System Library. If you're not sure where to post your message, do it here. However, do not make test posts here; that's the purpose of the Sandbox.
Post Reply
mikep
Posts: 796
Joined: 24 September 2005, 15:54 PM

Limit on size of System.Alloc

Post by mikep »

In my "manytask2.bas" stress test I tried to allocate a single heap area for all of the task stacks but System.Alloc returned a zero.

After some further work I then tried allocating an area of memory for counters where each counter used 2 bytes (instead of the original 1). I found that the maximum number of integer counters I could allocate was 1791. If you include two bytes for the allocation size, the maximum is 3584 bytes (or 3.5K exactly).

This maximum of 3582 bytes appears to be undocumented.

Naturally I would like to see this limit increased (to 64768 if possible). Then the maximum tasks can be raised from 2021 to 2156 ;)
Mike Perks
dkinzer
Site Admin
Posts: 3120
Joined: 03 September 2005, 13:53 PM
Location: Portland, OR

Re: Limit on size of System.Alloc

Post by dkinzer »

mikep wrote:This maximum of 3582 bytes appears to be undocumented.
The limit on the size of a single allocation request is currently hard-coded to be the size of internal RAM less the size of the portion set aside for system use. While this is suitable for devices without external RAM, it does impose an unnecessary restriction in cases where there is external RAM.

We are experimenting with some ideas to solve this problem and, at the same time, more reliably detect a collision between the Main() task stack and the heap.
- Don Kinzer
Post Reply