Memory leaks

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Memory leaks

jxjl
Hi I am trying to figure out how to destory objects in qooxdoo app. Code of my class looks as follow

/**
 * Error window with ok button
 */
qx.Class.define("main.ErrorWin", {
  extend : qx.ui.window.Window,
 
  /**
   * Constructor
   * @param text {String} text to be displayed in window
   */
  construct : function(text) {
    this.base(arguments, "Error");
    this.setModal(true);
    this.setShowMaximize(false);
    this.setShowMinimize(false);
    this.setMinWidth(300);
    this.setMaxWidth(800);
    this.addListener("resize", this._center , this);
    var text = new qx.ui.basic.Atom(text, "main/Status-dialog-error-icon.png");
    text.setRich(true);
    var mainLayout = new qx.ui.layout.VBox();
    var buttonBarLayout = new qx.ui.layout.HBox();
    var buttonBar = new qx.ui.container.Composite(buttonBarLayout);
    var button = new qx.ui.form.Button("OK");
    button.addListener("execute", this.close, this);
    buttonBarLayout.setAlignX("right");
    buttonBar.add(button);
    this.setLayout(mainLayout);
    this.add(text);
    this.add(buttonBar);
    this.addListener("close", this.clean, this);
    qx.util.DisposeUtil.disposeTriggeredBy(button, buttonBar);
    qx.util.DisposeUtil.disposeTriggeredBy(buttonBarLayout, buttonBar);
    qx.util.DisposeUtil.disposeTriggeredBy(buttonBar, this);
    qx.util.DisposeUtil.disposeTriggeredBy(text, this);
    qx.util.DisposeUtil.disposeTriggeredBy(mainLayout,this);
  },
 
  statics : {
    /**
     * Shows error window with text
     *
     * @param text {String} text to be shown in window
     */
    showError : function(text) {
      var errwin = new main.ErrorWin(text);
      var doc = qx.core.Init.getApplication().getRoot();
      doc.add(errwin);
      errwin.open();
    }
  },
 
  members : {
    /**
     * Center window on screen
     */
    _center : function(){
      this.center();
      this.removeListener("resize", this._center, this);
    },
   
    clean : function(){
      this.debug("closing");
      this.close();
      this.getLayoutParent().remove(this);
      this.debug("closing");
      qx.event.Timer.once(function(){
        this.debug("dispose");
        this.dispose();
      }, this, 5);
    }
  }

}
);

even I tried to dispose all created objects, each instance of this class results in 2 undisposed objects. Have I missed something or is it a bug?
Reply | Threaded
Open this post in threaded view
|

Re: Memory leaks

jxjl
I have finally found the solution

when I insert button directly to window it is disposed by destroy method, but when I add it to form and then I add the form to window it is not removed at all. Don't know why, but when I add text field to form, it is destroyed by form.disposse method.

Should we consider this behaviour as bug?
Reply | Threaded
Open this post in threaded view
|

Re: Memory leaks

MartinWittemann
Administrator
Hey,
usually, we do have a simple rule for disposing: The creator is responsible for disposing. This means, the one how is doing the „new“ call has to do the dispose. As you create the buttons, you should be responsible for disposing it (exceptions apply). But thats also true for the text field e.g. so no matter what, it should be equals for both and is worth a bug report. :)
Thanks,
Martin

> Am 01.03.2015 um 18:08 schrieb jxjl <[hidden email]>:
>
> I have finally found the solution
>
> when I insert button directly to window it is disposed by destroy method,
> but when I add it to form and then I add the form to window it is not
> removed at all. Don't know why, but when I add text field to form, it is
> destroyed by form.disposse method.
>
> Should we consider this behaviour as bug?
>
>
>
> --
> View this message in context: http://qooxdoo.678.n2.nabble.com/Memory-leaks-tp7586874p7586876.html
> Sent from the qooxdoo mailing list archive at Nabble.com.
>
> ------------------------------------------------------------------------------
> Dive into the World of Parallel Programming The Go Parallel Website, sponsored
> by Intel and developed in partnership with Slashdot Media, is your hub for all
> things parallel software development, from weekly thought leadership blogs to
> news, videos, case studies, tutorials and more. Take a look and join the
> conversation now. http://goparallel.sourceforge.net/
> _______________________________________________
> qooxdoo-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel