Hi adilb and Nauman
Thanks for your replies..
Here is how I determine the amount of free space:
Code:
public static void debugOutput(String msg)
{
if(DEBUG_SHOW_OUTPUT)
{
String fm = "Free mem: " + getFreeMem() + " - ";
if(DEBUG_SHOW_SPEED)
fm += debugMsPassedSinceLastOutput();
fm += msg;
System.out.println(fm);
if(_currentScreen != null)
_currentScreen.debugToFooter(fm);
}
}
public static String getFreeMem()
{
System.gc();
long tot = Runtime.getRuntime().totalMemory();
long free = Runtime.getRuntime().freeMemory();
int per = (int)(((float)free / (float)tot) * 100);
String s = gx.Utils.padString(String.valueOf(free), -8, " ") + " " + gx.Utils.padString(String.valueOf(per), -3, " ") + "%" + " / " + String.valueOf(tot);
return s;
}
I have tried string buffers to build the strings in the above example it made little difference so I removed them from this example for readability sake.
From my understanding what you are saying is that is that the platform is caching the form in memory, this cant be that drastic as the memory consumption I quoted was soon after the app starts.
I am certain that no other apps are running because I restarted the phone, I have the phone now for debugging purposes and am running tests on both phones simultaneously, also the nokia shows how much memory is free for applications in the memory status screen.
As mentioned originally the two devices are sonyerricson w800i and nokia 6131, the nokia is the problematic device.
the flow of the application is as follows:
public class ATRMidlet extends javax.microedition.midlet.MIDlet
-> public void startApp()
{
_navigator = new gx.Navigator(getDisplay(), this);
}
the navigator class keeps a reference to the midilet (this) so it can call exitMIDlet()
the navigator then loads the data from the recordstore
then the mainmenu form is initialised
public class MainMenuForm extends gx.Forms.BaseForm
public abstract class BaseForm implements gx.Forms.CustomForm.CommandListener
base form does the command handling and creates an instance of
gx.Forms.CustomForm() which does the handles items, it also extends customCanvas which does the painting
public final class CustomForm extends gx.Forms.CustomCanvas
-> public class CustomCanvas extends javax.microedition.lcdui.Canvas
the debugoutput is called at various points namely when painting here is some output from the emulator:
Free mem: 301928 73% / 409600 - Navigator started init
Free mem: 247224 60% / 409600 - CustomCanvas paint started
Free mem: 247032 60% / 409600 - CustomForm paintMain started
Free mem: 247032 60% / 409600 - CustomForm paintMain ended
Free mem: 247172 60% / 409600 - CustomCanvas paint ended
Free mem: 247172 60% / 409600 - CustomCanvas paint started
Free mem: 199272 48% / 409600 - CustomCanvas paint ended
Free mem: 199796 48% / 409600 - Navigator pre init icons
Free mem: 197412 48% / 409600 - Navigator pre init object handler
Free mem: 185064 45% / 409600 - ObjectHandler init started
Free mem: 147684 36% / 409600 - Navigator post init object handler
Free mem: 129896 31% / 409600 - BaseForm init started title: Basic menu
Free mem: 129820 31% / 409600 - CustomCanvas init started
Free mem: 129756 31% / 409600 - CustomCanvas init ended
Free mem: 129756 31% / 409600 - CustomForm init started
Free mem: 129740 31% / 409600 - CustomForm init ended
Free mem: 129452 31% / 409600 - BaseForm init ended
Free mem: 129428 31% / 409600 - MainMenuForm setMenuItems started
Free mem: 129348 31% / 409600 - MainMenuForm pre init menu cat items
Free mem: 124888 30% / 409600 - MainMenuForm post init menu cat items
Free mem: 124580 30% / 409600 - MainMenuForm setMenuItems ended
Free mem: 125104 30% / 409600 - Navigator ended init
Free mem: 123428 30% / 409600 - CustomCanvas paint started
Free mem: 122040 29% / 409600 - CustomForm paintMain started
Free mem: 122568 29% / 409600 - CustomForm paintMain ended
Free mem: 122692 29% / 409600 - CustomCanvas paint ended
at this point the main menu is displayed and waiting for user input.
as you can see there is 29% free memory 122692 of 409600 bytes
so at this point only one instance of canvas is created and at the same point on the nokia with 2mb RAM it reports 1170432 of 2097152 bytes 55%
when the next form is loaded it reports less an less free memory whereas the sonyerricson reports between 80% and 70% free
so System.gc() is being called before I check for free space, and I am currently finding all the points where I can set objects = null and doing so has had little improvement.
my apologies for the long post
GX