Too Many Objects Error

My app works perfectly on the watch in my "Sim" mode (for development/testing) when replaying an old yacht race, but crashes with "Too Many Objects Error" when running with live data from the GPS.
It looks to me like Position.enableLocationEvents(Position.LOCATION_CONTINUOUS, method(:GPSData)); is generating objects, but that doesn't make any sense really.
In my "Sim" mode, I'm calling my app's main processing function with data that I'm retrieving from my web site.
In live mode, I'm calling it with data from the Position.enableLocationEvents callback.
Other than that the two modes are identical.
In "Sim" mode. the app runs for an entire race of over 2 hours.
In Live mode, it crashes after around two minutes.
ERROR: Too Many Objects Error
DETAILS: Failed invoking <symbol>
STORE_ID: 00000000000000000000000000000000
CALLSTACK:
144)*Failed while writing stack trace*

I'm monitoring memory each callback cycle, and memory usage remains static up to the crash.
Memory Total:125272 Used:101208 Free:24056


Sure, I'm pushing the watch, running with around 24Kb free, but with no way to monitor object usage, I'm in a big hole.
The issue has started since I added the latest feature which has increased memory usage by around 30Kb.
Any thoughts (before I slit my throat)?
  • Maybe these untested functions will help?

    module Degrees
    {
    hidden static const _D2R = Math.PI / 180.0;
    hidden static const _D2B = 0x7FFFFFFF / 180.0;

    function toRadians(x) {
    return x * _D2R;
    }

    function toBilli(x) {
    return (x * _D2B).toNumber();
    }
    }

    module Radians
    {
    hidden static const _R2D = 180.0 / Math.PI;
    hidden static const _R2B = 0x7FFFFFFF / Math.PI;

    function toDegrees(x) {
    return x * _R2D;
    }

    function toBilli(x) {
    return (x * _R2B).toNumber();
    }
    }


    module Billi
    {
    hidden static const _B2D = 180.0 / 0x7FFFFFFF;
    hidden static const _B2R = Math.PI / 0x7FFFFFFF;

    function toDegrees(x) {
    return x * _B2D;
    }

    function toRadians(x) {
    return x * _B2R;
    }
    }
  • Former Member
    Former Member
    using 0x80000000 will work if you want to use it, but you will need to use it as 0x80000000l (a long), because as Travis pointed out, it is a negative number as a number.

    I think just using 0x7FFFFFFF is fine, and will be faster due to not needing to use a long, so that is probably a good idea.
  • Thanks guys, I now see that 0X80000000 is indeed a 32-bit signed integral (Lang.Number) with the value -2147483648, and 0X7fffffff overcomes that, but 0X80000000d also does the trick!
    (Ah! the joys of a Duck-typed language!)