Jump to content
Sign in to follow this  
faguss

Single Allocation Limit

Recommended Posts

As you know:

As single memory allocation in OFP is limited to 256 MB and one array element slot uses 4 B, you certainly cannot have array bigger then 6 M (6.7 millions). In practice you will also need some memory to contain content of elements.


I have found out that the maximal amount of items in an array (for a single allocation) is 256. 4B * 256 = 1KB.

If an array has sub-arrays with one element the limit is still 256. If each of those sub-arrays contain two items then the limit is 255. If three - 254 and so on. Things get complicated if the sub-arrays are irregular like here. Main matrix has 253 elements. Smallest sub-array has 2 items, biggest - 17. In total there are 1166 numbers.

How to calculate how much space an array takes to avoid errors?
  • Like 1

Share this post


Link to post
Share on other sites

Not really sure how it's code is written; but I think it would be 240. In your above example: "If an array has sub-arrays with one element the limit is still 256." -|> this would equal 256-0=256. Then it's logical to conclude: 17 -1= 16 , 256-16= 240. I would tend to doubt they wrote code to pick up on anything more than amount of subarray's with largest elements. But hey who knows maybe the coder(s) were industrious. That would be my guess. It could be a start point to look for errors.

  • Like 1

Share this post


Link to post
Share on other sites

To clarify - the limit for that array is 253 elements so it's not "just the highest determines".

To further complicated things: I've tried creating an array with largest possible amount of values (for a two-dimensional matrix) and ended up with this. When I moved a number from one sub-array to another the game failed to allocate (error).

Then I reversed it and now the limit is only 128. So placement does seem to matter.

EDIT: No, wait. The limit is 256 but next sub-arrays must be smaller. I still can't move numbers in the lower half but I can add new to upper half (and essentially coming back to our reverse pyramid).

Edited by Faguss
  • Like 1

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×