Data too large for Background process

Former Member
Former Member
The app I wrote has a background process which parses a JSON file every 30 minutes. Used to work fine, but the past couple of weeks it's been having issues. Looking at the logs, the error that pops up is:

Message: Data provided to Background.exit() is too large

The file is only 1.2Kb. That doesn't seem too large. Anything else which may be triggering this error?
  • I wrote some code a while back to do string interning on object hierarchies (like a json document). It won't get as much savings as what you're doing above, but it is generic and leaves the document essentially unmodified.

    Edit: According to Brian.ConnectIQ this is done automatically before the json data is passed off to the application. I haven't verified this, but he usually knows what he's talking about.. :)

    function _intern_string(s, m) {
    var found = m.get(s);
    if (found != null) {
    return found;
    }

    m.put(s, s);
    return s;
    }

    function _intern_dict(d, m) {
    var vals = d.values();
    var keys = d.keys();

    // reduce memory consumption of common map keys
    for (var i = 0, j = keys.size(); i < j; ++i) {
    var key = intern(keys, m);
    d.put(key, vals);
    }

    return d;
    }

    function _intern_list(s, m) {
    for (var i = 0, j = s.size(); i < j; ++i) {
    s= intern(s, m);
    }

    return s;
    }

    function intern(obj, map) {
    if (obj instanceof Lang.Dictionary) {
    return _intern_dict(obj, map);
    }
    else if (obj instanceof Lang.Array) {
    return _intern_list(obj, map);
    }
    else if (obj instanceof Lang.String) {
    return _intern_string(obj, map);
    }

    return obj;
    }
    [/code]

    You'd use it like this...

    var cache = {};
    json = intern(json, cache);
    cache = null;