Ticket Created
over 4 years ago

WERETECH-11175

set/getProperty deprecate on sdk 4?

In current doc something has changed!!

Previous information: some function (e.g. deleteProperty) was planned to remove but not set/get.

My app run well and there are values in sim Application.AppBase.Data.

So, is documentation correct?

I have some strange app behaviour on sim:

- settings don't change

- memory peaks

- console  message "Unable to serialize app data"

- resetting settings to default

can be connected with any changes in sdk 4?

  • oh no... I've asked about several time and I was almost sure that length of var name has influence of memory consumption even though I felt it shouldn't.

  • "For me it's strange, when you analyse debug.xml there is numbers for object/function so every var, const etc should by change to number during compilation especially for "script language" when vm have to analyse every char and it cost memory and processor."

    Monkey C isn't a "script" language tho. My understanding is that Monkey C is compiled into intermediate bytecode, like Java or C#.

    I tried this a couple of years ago when I started playing around with saving memory in Monkey C, and I tried it today: I ran my app, then I changed the length of global, class and local variable names, and ran it again -- the amount of memory taken up at run time was identical in both cases. Notably, the code and data size did not change.

    OTOH, if make a significant change to code -- e.g. replace if (x) with if (x != null) -- you will see the code size increase. And if you add a variable, you may see both the code size and data size increase.

    But you can try for yourself. Just replace all instances of mValueRange in your code with mValueRange_ridiculouslyLongVariableName and see if there's any memory impact in the sim. I don't think there will be.

    Note that to implement things like callback functions, you use symbols to refer to functions (and not strings). Symbols are also how one class refers to a field in another class. Note that the size of a symbol is constant and doesn't depend on the length of the identifier in code, as far as I can tell. I'm pretty sure that if you open a PRG file in a hex editor / text editor, you would see text for your property names and literal strings, but you wouldn't see text for any of your function or variable names.

  • You can say that length of var has no matters because all code exist in the same area of memory (and maybe additionaly when function is called).

    For me it's strange, when you analyse debug.xml there is numbers for object/function so every var, const etc should by change to number during compilation especially for "script language" when vm have to analyse every char and it cost memory and processor.

    This my class declaration example:

               
        var     
                mVs,// = "",           
                mCT = 1,          
                mSV,               
                
                mVv,               
                mVn,                
                mVx,                
                mDn,                             mDx,               
                mValueRange,        
                mVl,               
                mVg,              

               AND SO ON...

    and function

        function drawV(v, x, y, dc, c)
        {
            if((y == null) || ((mSV != null) && (v != null) && (v > mSV)))
            {
                return;
            }
    horrible...

    of cource I can save some memory removing m from members and use d instead dc or name dV instead drawV  - a lot place to reduce memory :)

    the problem is whith Garmin code, not do anything e.g. getProperty should shorten to gP :)

  • "We spend hours to fight with limitation of system, the worst it's keeping in my memory code, each lines of code lower my memory, most of variable has 1 or 2 chars, code is horrible."

    I agree that we have to write horrible code to save memory in Connect IQ, and that some of these limitations are very frustrating (you can see me complaining in the forums all the time haha).

    However, I don't think the length of your variable names matters (local, class or global variables) -- your variable names can be any length you want and they'll take up the same amount of code/data space in memory. You can def save memory by having fewer variables, and *maybe* by having fewer unique variable names (as a symbol as automatically created for each new name -- I'm just not sure if it makes a difference at runtime)

    The length of *property names* matters because they'll be stored as keys in the property dictionary.

  • I know about 2 copy of properties (had memory problem) so for bigger data set first null and than correct values (system probably set new value and if it is saved correct delete old and change name).

    Of course system call onSettingsChanged() but if getProperty is deprecated how to read this settings?

    2 copies of settings.. How to manage memory if I don't know how it handle system? How many free memory I have to have?

    92kb

    - background uknown

    - ??? settings 1x or 2x

    --??? properties 1x or 2x

    We spend hours to fight with limitation of system, the worst it's keeping in my memory code, each lines of code lower my memory, most of variable has 1 or 2 chars, code is horrible. There is graphics pool (bwt what is the size of it), the same should be with code and non user data.