From: Joshua M. <xm...@me...> - 2010-05-24 16:38:47
|
Hi Panayotis, I am aware of this issue and have been working on a fix for it. Sadly, the fix is non trivial though I am making (slow) progress on it. For now, the best workaround is to comment out // new ExcessRetainsOptimization().Process(curRun.allCodePaths, curRun.beenTo, // codeElement); in ReferenceCounting.java. Since this bug is affecting people, I will talk to Arno about checking in that workaround until I can actually implement a correct fix. Sorry you encountered this... -- Joshua Melcon On Mon, May 24, 2010 at 6:28 AM, Panayotis Katsaloulis <pan...@pa...> wrote: > I think I found a serious memory bug with current implementation of xmlvm. > > Here is the minimum java code to reproduce this bug: > > package xmlvm; > import org.xmlvm.iphone.UIApplication; > import org.xmlvm.iphone.UIView; > > public class Main extends UIApplication { > public void applicationDidFinishLaunching(UIApplication app) { > testView view = new testView(); > } > public static void main(String[] args) { > UIApplication.main(args, Main.class); > } > public class testView extends UIView { > public testView() { > System.out.println(getFrame().size); > } > } > } > > > the initialization code of testView produces this code: > > - (void) __init_xmlvm_Main_testView___xmlvm_Main :(xmlvm_Main*)n1 > { > XMLVMElem _rtmp; > XMLVMElem _r0; > XMLVMElem _r1; > XMLVMElem _r2; > XMLVMElem _r3; > _r2.o = self; > _r3.o = n1; > _r0.o = JAVA_NULL; > _r1.o = JAVA_NULL; > [_r3.o retain]; > [((xmlvm_Main_testView*) _r2.o)->this_0_xmlvm_Main release]; > ((xmlvm_Main_testView*) _r2.o)->this_0_xmlvm_Main = _r3.o; > [((org_xmlvm_iphone_UIView*) _r2.o) __init_org_xmlvm_iphone_UIView__]; > _r0.o = [java_lang_System _GET_out]; > _r1.o = [((xmlvm_Main_testView*) _r2.o) getFrame__]; > _rtmp.o = _r1.o; > _r1.o = ((org_xmlvm_iphone_CGRect*) _r1.o)->size_org_xmlvm_iphone_CGSize; > [_rtmp.o release]; > _rtmp.o = JAVA_NULL; > [((java_io_PrintStream*) _r0.o) println___java_lang_Object:_r1.o]; > return; > } > > > > Now, let me copy & paste the code and add some comments, to describe it: > // perform getFrame() > _r1.o = [((xmlvm_Main_testView*) _r2.o) getFrame__]; > > // keep result of getFrame() into temporary variable _rtmp > _rtmp.o = _r1.o; > > // frame's size is received from the structure > _r1.o = ((org_xmlvm_iphone_CGRect*) _r1.o)->size_org_xmlvm_iphone_CGSize; > > // **release frame ** - here is the bug > [_rtmp.o release]; > _rtmp.o = JAVA_NULL; > > // Use CGSize data, although the structure that was encapsulating it (the frame) is already freed! > [((java_io_PrintStream*) _r0.o) println___java_lang_Object:_r1.o]; > > > > It seems that objects whose member items are used later on, should also be tracked and released ONLY after the inside items are not used any more! > Or, even better, every time a reference with the -> operator is made, also retain this object and properly release it afterwards. > > What others do say? > ------------------------------------------------------------------------------ > > _______________________________________________ > xmlvm-users mailing list > xml...@li... > https://lists.sourceforge.net/lists/listinfo/xmlvm-users > |