Shop OBEX P1 Docs P2 Docs Learn Events
ERROR: Object exceeds runtime memory limit by X longs — Parallax Forums

ERROR: Object exceeds runtime memory limit by X longs

beckhart13beckhart13 Posts: 4
edited 2007-12-05 03:16 in Propeller 1
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....

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2007-12-01 16:35
    You'll have to attach examples of the code that exceeds the # of longs limit.
    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.
  • deSilvadeSilva Posts: 2,967
    edited 2007-12-01 16:44
    This is well known situation with all graphics_drv, be it the Hydra drivers or others.

    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....
  • beckhart13beckhart13 Posts: 4
    edited 2007-12-01 17:20
    thanks for reply... here is the if statement structure that when commented is running fine and
    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
  • Mike GreenMike Green Posts: 23,101
    edited 2007-12-01 17:55
    1) You need to use the code tags when posting code like this "[noparse][[/noparse] code ]" and "[noparse][[/noparse] /code ]" without the extra spaces. Even so, some things like "[noparse][[/noparse] 1 ]" and "[noparse][[/noparse] 2 ]" get stripped out since they have special meaning to the message formatter.

    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.
  • beckhart13beckhart13 Posts: 4
    edited 2007-12-01 18:50
    Ok Mike I took your advice and threw my if construct out the window and went w/ a CASE construct.
    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?
  • Mike GreenMike Green Posts: 23,101
    edited 2007-12-01 18:56
    Yes, read deSilva's comments.

    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.
  • hal2000hal2000 Posts: 66
    edited 2007-12-03 14:20
    Hello.
    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 Englishblush.gif
  • hal2000hal2000 Posts: 66
    edited 2007-12-04 12:50
    Beckhart13
    I optimized graphics library
    It weighs less, leaving more room for your program
    They removed the little things that are used (vectors arches etc.) nono.gif

    It incorporates a new function (gr.dec) for easy printing numerical data

    Tonight put it on the forum.
  • hal2000hal2000 Posts: 66
    edited 2007-12-04 22:00
    These are the libraries
    is in "PAL"
    Not NTSC
    Greetings
  • beckhart13beckhart13 Posts: 4
    edited 2007-12-05 03:16
    thanks hal2000
    i will give it a shot
Sign In or Register to comment.