Discussion

Out of memory

0

moechofe 2020-08-21 05:18

@timo can you explain how memory is consumed?
I got a memory error message on an assignement like this one:
bonus=bonus+125


was8bit 2020-08-21 07:26

One way is to have a "loop" thst doesnt return... meaning something like....

GOSUB ADDBONUS

ADDBONUS:
BONUS=BONUS+125
GOTO REPLAY

NX never gets to a RETURN, so it keeps in memory the layers of GOSUBS in a stack until the the whole stack gets used up... it usually its at loop 128.. but then again it yields a "stack overflow" error....

Recheck your code carefully for anything odd in how it is behaving... maybe add tests that PRINT stuff out to help verify and track that your code is doing and behaving as you think it should....


Timo 2020-08-21 08:40

Just checked my code again: Out Of Memory can happen in two cases:

- The memory of your computer is really full. But this probably never happens these days.

- One of the internal arrays of the interpreter is full. They all have fixed sizes.

Looks like you have more than 128 variables! But I never meant these limits as part of the fantasy console design, I just thought it's enough. I can double the limits in version 1.1. There is no faster solution, sorry.

Basically version 1.1 is ready, but I still wanted to add GameShell support for this release and I'm waiting for some documentation from its maker.


Timo 2020-08-21 08:45

I can make a new beta for iOS quickly, so you can continue developing. But you couldn't publish it until the public release of 1.1.


moechofe 2020-08-21 08:45

Did local variables in subprogram take part of the 128 limitations?

e.g
'127 global variables already used

call goo

sub goo
g=123
call bee
end sub

sub bee
b=234
end sub

goo and bee both use 1 local variable, so it got a total of 129 variables

(I think i should test-it myself)


moechofe 2020-08-21 08:53

I tested it, and Yes it fails


Timo 2020-08-21 08:54 (Edited)

Yes, it's 128 variables in total (+ 128 arrays).
Hm, thinking about recursion, I should probably even make it more than the double.


moechofe 2020-08-21 09:00

@was8bit I think the error you describing is STACK OVERFLOW

a=0
gosub goo
goo:
print str$(a)
inc a
gosub goo


was8bit 2020-08-21 12:14 (Edited)

@moechofe, yep... but whenever you push NX to its limits, it may occaisonally give you an error message that doesnt directly match what may have initiated the problem... that is, the initial problem may cascade into an additional problem....

Anytime i have a problem that isnt immediately evident, i try backgracking my code until the problem goes away... but if i did too many changes without testing each change first, it gets trickier and at that point I start adding lots of PRINT or PLAY with WAIT commands so i can see and hear my code performance at key points, and try to narrow down WHERE in the code does the problem pop up....

i may add REM in front of certain lines of code until i get the error message to go away, then start removing some REM until the error message pops up again..,


Log in to reply.