Parser Stack Overflow - is this the limit?

Discussion in 'Scripting Workshop' started by Lovechld2000, Sep 22, 2018.

  1. Lovechld2000

    Lovechld2000 NI Product Owner

    Messages:
    196
    I was building something with a ton of controls and saw this error that goes away when removing some variables. Am I right in thinking I have gone past the limit of ksp?
     
  2. EvilDragon

    EvilDragon Moderator Moderator

    Messages:
    13,916
    Sounds like you have a pretty huge init callback. I'm not sure how bit the limit there is, perhaps 20000 lines or something, dunno. A workaround is having sections of code enclosed in an always-executing if clause. Like so:

    Code:
    if (1=1)
    <a bunch of code>
    end if
     
  3. Lovechld2000

    Lovechld2000 NI Product Owner

    Messages:
    196
    It's about 9000 lines but there are a whole lot of variables and large arrays, enough controls for 16 sampler synths with a mixer that has heaps of fx, copy paste features, 16 sequencers and another multi gate layer selector system. I'm trying to recreate something like a full featured wavestation

    I looked in general computer science forums and that said this error type is generally too much memory assigned to variables. I assume constants are much more space saving. I haven't checked compact variables yet in sublime. Maybe that will help. I didn't know about the ~always if~practice. Is that specific to kontakt? Is there more to know about that and how to make the most of it?
     
  4. EvilDragon

    EvilDragon Moderator Moderator

    Messages:
    13,916
    I can't suggest anything more specific without looking at your code, but in general, try to make the initialization of UI controls leaner. For example, I put all control parameters (x, y, width, height, default value, mouse behavior, allow automation, font type, textpos y...) in ONE array, one row for each control, then just loop through that setting all those control pars for all controls, which makes it quite efficient...
     
  5. Lovechld2000

    Lovechld2000 NI Product Owner

    Messages:
    196
    thanks for the tips. 2 questions.
    1. Is one huge array better than a set of arrays? I have 17 arrays that have 200 elements each in one situation, is that better as 1 array with 3400 elements?
    2. Do I get another block of memory if I start another script , like have a mixer script and just pgs anything i need over?
     
  6. EvilDragon

    EvilDragon Moderator Moderator

    Messages:
    13,916
    1. There are no rules here, but in general if it's closely related data (i.e. all the control pars), it makes sense to have one huge array. Especially if you use it as a 2D array in SublimeKSP, then it's quite easy to access a particular control par for a particular UI control.

    2. Yeah that sounds logical.
     
  7. Lovechld2000

    Lovechld2000 NI Product Owner

    Messages:
    196
    i didn't fancy my chances being allowed controls for all 16 layers so I set up 16 arrays that update the controls and the knobs, like you demonstrated for me in your range selector, and i built the whole thing with macros with their parameters holding all the settings. amazing how fast so much code appears. thanks again for your assistance brother
     
  8. franto

    franto NI Product Owner

    Messages:
    34
    yes, I got similar problem and "if workaround" helped me as well.
     
  9. Lovechld2000

    Lovechld2000 NI Product Owner

    Messages:
    196
    an interesting footnote to this, after I deleted a bunch of variables associated with controls, (sliders and read out labels mainly)
    I was subsequently allowed to add several more large arrays and other normal integer variables that together i would have thought needed more memory.
    I also followed the advice of putting large arrays in on init with the statement if (1 = 1) <arrays> end if. I have not seen the message come back.