Meet memory leak when using Layer

Dear Kinoma fellow,

When using Layer to implement transition, memory leak is observed. Use the code below to reproduce: var ui = new Label(); application.add(ui); var testlayer = new Layer; testlayer.attach(ui); testlayer.detach(); trace("a"); application.remove(ui); Each time the code is executed, the memory cost keeps increasing by several kilo Bytes. If comment out the 3 lines, the memory leakage can't be reproduced. var testlayer = new Layer; testlayer.attach(ui); testlayer.detach();

My kinoma version is Fsk7.0.18 on linux.

Answers

  • Format the code:

    var ui = new Label(); application.add(ui); var testlayer = new Layer; testlayer.attach(ui); testlayer.detach(); trace("a"); application.remove(ui);

    Each time the code is executed, the memory cost keeps increasing by several kilo Bytes. If comment out the 3 lines, the memory leakage can't be reproduced.

    var testlayer = new Layer; testlayer.attach(ui); testlayer.detach();

  • If I call application.purge(), it seems the memory doesn't keep increasing. So I guess the garbage collection need to be done. In technique note, there is a article about GC. One sentence is "Notice that the GC almost never runs except when entering on a new screen." If there is only some floating UI shown instead of full screen UI shown, will the garbage collection happen?

  • edited November 2015

    Tony,

    As you remove these objects from your application they are becoming eligible for garbage collection. The actual garbage collection will happen as needed, without being explicitly called. As this collection is not done in immediate response to objects becoming collectible, some memory fluctuation is to be expected.

    Is this small example representative of a larger issue you're facing? If so, please provide some more information and I'll be happy to look into it for you.

    Cheers,

    Will

  • Hi Will,

    Thanks for your response. I am investigating one crash issue which is caused by out of memory. It seems the Kinoma UI process costed more and more memory. I will provide more info when I can reproduce this issue.

    Thanks Tony

Sign In or Register to comment.