circular reference

This code seem to create a circular reference :


class archeryModel
{
...
hidden var _shotProcess = null;
....

function initialize() {
...........
_shotProcess = new ShotProcess(self);
}

}

class ShotProcess {
....
var _model;
...
function initialize(model) {
_model = model; // seems to cause circular ref !
...
}



but i don't understand, how can i wrote it differently !
note : i've try to use _model = Application.getApp().model; instead, but in that case, when I call some functiojn in the model (like _model.myFunc() ) it exit wit ha non existent function !


  • Last time I ran into an issue with circular references was probably a year plus back, and what I saw was that when the app was exited in the sim, it could pop up a message and offer to open the memory viewer so you could see what was going on.

    If I recall, to resolve it I did something like Travis suggested in onStop. At the time, it could have been Brian that said that the app would shutdown and clean up fine, because at that point, it was just dealing with the memory as a whole.

    Since I fixed it in the sim, I never saw it with a sideload, so the thing I don't know is if it logged something to ciq_log.
  • I'm curious what would happen (if anything) if you just ignored the circular references and let the app exit.

    Since each application has its own heap and the heap is completely destroyed when the app exits, no memory is leaked. But if you are running under the simulator I believe you'll see a message and then the memory viewer will be displayed. This can be pretty annoying if you are running the app under the simulator a lot.