ERROR: Object exceeds runtime memory limit by X longs
I keep getting this error from a simple spin program using the following drivers:
tv : "tv_drv_010.spin"
gr : "graphics_drv_010.spin"
It seems a group of nested if statements w/ multiple ANDs and ORs is increasing the number
of longs immensely.
When I delete code to the point to where I am under the # of longs limit and check the documentation
it says I have
Program: 1,783 Longs
Variable: 241 Longs
I was under the impression I had over 8,000 longs to work w/.
Any help would be appreciated....
tv : "tv_drv_010.spin"
gr : "graphics_drv_010.spin"
It seems a group of nested if statements w/ multiple ANDs and ORs is increasing the number
of longs immensely.
When I delete code to the point to where I am under the # of longs limit and check the documentation
it says I have
Program: 1,783 Longs
Variable: 241 Longs
I was under the impression I had over 8,000 longs to work w/.
Any help would be appreciated....
Comments
You do have approximately 8000 longs to work with. Normally a group of
nested if statements with multiple ANDs and ORs should not make that much
difference, so there must be something else going on.
You need an extreme amount of memory when double buffering. As these buffers are not allocated regularly by VARs (mostly due to lack of allignment options in SPIN) they are directly addressed in memory and the _STACK option is used to prevent any harm.
The error message says - in other words - that your program reached the point where the stack must start.
And of course there is always the single last drop....
when uncommented is throwing me 122 longs over the limit
clickIndex, blankIndex, and mapRender[noparse]/noparse are all declared as words in VAR
if(clickIndex == 0)
if((mapRender == 5) or (mapRender[noparse][[/noparse]6] == 5))
blankIndex := 1
elseif((clickIndex == 1) or (clickIndex == 2) or (clickIndex == 3) or (clickIndex == 4))
if((mapRender[noparse][[/noparse]clickIndex - 1] == 5) or (mapRender[noparse][[/noparse]clickIndex + 6] == 5) or (mapRender[noparse][[/noparse]clickIndex + 1] == 5))
blankIndex := 1
elseif(clickIndex == 5)
if((mapRender == 5) or (mapRender[noparse][[/noparse]11] == 5))
blankIndex := 1
elseif(clickIndex == 6)
if((mapRender[noparse][[/noparse]0] == 5) or (mapRender[noparse][[/noparse]7] == 5) or (mapRender[noparse][[/noparse]12] == 5))
blankIndex := 1
elseif((clickIndex == 7) or (clickIndex == 8) or (clickIndex == 9) or (clickIndex == 10))
if((mapRender[noparse][[/noparse]clickIndex - 1] == 5) or (mapRender[noparse][[/noparse]clickIndex + 6] == 5) or (mapRender[noparse][[/noparse]clickIndex - 6] == 5) or (mapRender[noparse][[/noparse]clickIndex + 1] == 5))
blankIndex := 1
elseif(clickIndex == 11)
if((mapRender == 5) or (mapRender[noparse][[/noparse]10] == 5) or (mapRender[noparse][[/noparse]17] == 5))
blankIndex := 1
elseif(clickIndex == 12)
if((mapRender[noparse][[/noparse]6] == 5) or (mapRender[noparse][[/noparse]13] == 13))
blankIndex := 1
elseif((clickIndex == 13) or (clickIndex == 14) or (clickIndex == 15) or (clickIndex == 16))
if((mapRender[noparse][[/noparse]clickIndex - 1] == 5) or (mapRender[noparse][[/noparse]clickIndex - 6] == 5) or (mapRender[noparse][[/noparse]clickIndex + 1] == 5))
blankIndex := 1
elseif(clickIndex == 17)
if((mapRender[noparse][[/noparse]11] == 5) or (mapRender[noparse][[/noparse]16] == 5))
blankIndex := 1
else
blankIndex := 0
2) 122 longs is a bit much, but there are a lot of subscripts and complex Boolean expressions. One change would be to substitute "clickIndex => 7 and clickIndex =< 10" for a range like "(clickIndex == 7) or (clickIndex == 8) or (clickIndex == 9) or (clickIndex == 10)".
3) You might also compare the space needed for a "CASE clickIndex" statement to that needed for the IF ELSEIF chain. I don't know if it would save you much, but it would be worth a try.
4) 122 longs is only a small fraction of 8192 longs. You might be able to save a few longs here and a few longs there, but you're really up against a wall. You may need to rethink how you're doing things, possibly eliminate the graphics double buffering and update the display only during the vertical retrace interval or accept some smearing and flickering as the display is updated.
With a couple of other small altercations a slimmed it down enough to get it to compile.
After it would compile I went to the documentation radio button inside the Propeller IDE, and it gave
me relatively small numbers for my Long count :
Program: 1,792 Longs
Variable: 235 Longs
Obviously this number is nowhere close to 8000, but if I declare 2 more Longs I break the limit and error
is thrown again. Any ideas why this is happening?
The graphics and video drivers use space normally occupied by the stack for their buffers and the "_stack" and "_free" constant definitions reduce the amount of memory available. As I mentioned, you'll probably have to do without the graphics double buffering to get more memory.
This same thing happens to me.
That routine chart consumes a lot of memory, this is the problem
It would be better graphic library more efficient and less color.
2 colors is enough to show graphics and data
So I think that the buffer would be much smaller and would have more space for the program.
I do not control asembler, it is a pity
I think it is the only way to have a routine that allows graphic display graphics without blinking, obtimizar resources and the stack memory
Sorry for my English
I optimized graphics library
It weighs less, leaving more room for your program
They removed the little things that are used (vectors arches etc.)
It incorporates a new function (gr.dec) for easy printing numerical data
Tonight put it on the forum.
is in "PAL"
Not NTSC
Greetings
i will give it a shot