Home AMX User Forum AMX General Discussion
Options

Defaults for variable declarations

I'm suddenly running into problems where I run out of non volatile memory and my variables and arrays wont show any value in debug.

I have been able to correct the issue by going back and explicitly declaring all variables as VOLATILE ( I know I should have been doing this already.)

Did the defaults change in Studio 3 or something? I never bothered with this before and never had a problem?

Comments

  • Options
    mpullinmpullin Posts: 949
    Nope, it's always been like that.
  • Options
    PhreaKPhreaK Posts: 966
    Have you / code that you have loaded changed you're duet memory allocation? This comes out of the same memory (I think).
  • Options
    viningvining Posts: 4,368
    Given the fact that the majority of variables should be declared as volatile and very few variables need to be non-volatile I wonder why the default is the reverse of what it should be.
  • Options
    DHawthorneDHawthorne Posts: 4,584
    The thing to really watch is modules. It's easy to miss default declarations in them, and if you are running more than one instance, the problem multiplies.
  • Options
    ericmedleyericmedley Posts: 4,177
    I've never put anything but volatiles in a module. I didn't think you could put nonvolatiles and/or persistent cars in a module???
  • Options
    DHawthorneDHawthorne Posts: 4,584
    ericmedley wrote: »
    I've never put anything but volatiles in a module. I didn't think you could put nonvolatiles and/or persistent cars in a module???

    You can't put persistents in a module, but like anything else, if you don't specify volatile when you declare a variable in DEFINE_VARIABLE in a module, it defaults to non-volatile. If it's one of those modules that you need to make an instance for every UI device, you can run out of non-volatile memory real fast ... it's especially a problem dealing with someone else's module, as it's far more likely to slip past you.
  • Options
    ericmedleyericmedley Posts: 4,177
    DHawthorne wrote: »
    You can't put persistents in a module, but like anything else, if you don't specify volatile when you declare a variable in DEFINE_VARIABLE in a module, it defaults to non-volatile. If it's one of those modules that you need to make an instance for every UI device, you can run out of non-volatile memory real fast ... it's especially a problem dealing with someone else's module, as it's far more likely to slip past you.

    Yeah, any time I've needed to use a persistent variable in a module, I just read/write the value(s) to a file.
  • Options
    viningvining Posts: 4,368
    ericmedley wrote: »
    Yeah, any time I've needed to use a persistent variable in a module, I just read/write the value(s) to a file.
    or create a persistent var outside the module and pass it in as a parameter. If using multiple instances I'll create a persistent array and pass in the index of the persistant var that matches the instance of the module. Basically cuz sometimes I'm too lazy to read & write.
Sign In or Register to comment.