🔒 Locked
application error.
Advertisement
Original Post
Most times that means that you have gone out of memory.
McMc
McMc
or you try to access some object you didnt create.
try to monitor your memory by using the two runtime methods (one gets available-memory the other one free-memory - dont know the names at the moment, sorry) and run the garbage collector to get correct results...
greetings and such - atomhamster
try to monitor your memory by using the two runtime methods (one gets available-memory the other one free-memory - dont know the names at the moment, sorry) and run the garbage collector to get correct results...
greetings and such - atomhamster
I ran a test on my S55 and it seems to call the garbage collector by itself very frequently - at least once per second. If the Nokia 7210 emulator is anything like the actual phone, then that phone only runs the GC when it can''t fit an allocation into the remaining memory. (Then it goes and reclaims all it can; and if it still can''t fit in your allocation then you of course crash and burn.)
If you get a message about a NullPointerException - well then, it could hardly be any clearer what''s going on there; the code''s trying to invoke a method on a null reference, or otherwise use null in a way that requires a non-null.
Btw, the methods you''re looking for are Runtime.freeMemory() and Runtime.totalMemory(). These are non-static methods but Runtime is a singleton; so following the usual singleton paradigm of the Java library writers, you have to write something like
long freemem = Runtime.getRuntime().freeMemory();
long totmem = Runtime.getRuntime().totalMemory();
I have the javadoc for MIDP 1.0 downloaded on my HD, but I cannot for the LIFE of me find it on Sun''s website anymore, even though their navigation system seems to exude a certain sense of pride. (it''s not too hard to find the CLDC javadoc though; but that won''t tell you about all the javax.microedition.lcdui stuff...)
If you get a message about a NullPointerException - well then, it could hardly be any clearer what''s going on there; the code''s trying to invoke a method on a null reference, or otherwise use null in a way that requires a non-null.
Btw, the methods you''re looking for are Runtime.freeMemory() and Runtime.totalMemory(). These are non-static methods but Runtime is a singleton; so following the usual singleton paradigm of the Java library writers, you have to write something like
long freemem = Runtime.getRuntime().freeMemory();
long totmem = Runtime.getRuntime().totalMemory();
I have the javadoc for MIDP 1.0 downloaded on my HD, but I cannot for the LIFE of me find it on Sun''s website anymore, even though their navigation system seems to exude a certain sense of pride. (it''s not too hard to find the CLDC javadoc though; but that won''t tell you about all the javax.microedition.lcdui stuff...)
Zahlman: Where did you get those docs??
I have to google everytime I need to know something.
The null pointer exception you get is most likely caused by you not instantiating an object.
ie:
int a[];
a[4] = 1;
or
MyObject a;
a.myMethod ();
Get a trace of your execution and find out what threw the exception. If you can''t trace, make use System.out.println() to track it down.
Regarding your gc woes, make sure you have a wait() in your main loop. If you don''t do this then the GC will be ineffective.
If this doesn''t solve the problem you can manually force the GC to run via System.gc().
Best of luck,
Will
The null pointer exception you get is most likely caused by you not instantiating an object.
ie:
int a[];
a[4] = 1;
or
MyObject a;
a.myMethod ();
Get a trace of your execution and find out what threw the exception. If you can''t trace, make use System.out.println() to track it down.
Regarding your gc woes, make sure you have a wait() in your main loop. If you don''t do this then the GC will be ineffective.
If this doesn''t solve the problem you can manually force the GC to run via System.gc().
Best of luck,
Will
quote:
Original post by RPGeezus
Zahlman: Where did you get those docs??I have to google everytime I need to know something.
I got them off the Sun website... but I CAN''T FIND THEM ANYMORE
Re wait(), I don''t have one in my main loop but I do have a sleep() which I guess amounts to the same thing... heh :/ I also heard that in some cases using Display.callSerially() can be preferable.
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement