×

Discussion Board

Results 1 to 7 of 7
  1. #1
    Registered User
    Join Date
    Apr 2007
    Posts
    35

    Increasing memory problem & "Unable to run application" error

    Hello all once again !
    I have 2 questions regarding j2me:

    1. [MIDP 2, WTK 2.2]
    I have several continuously moving target (in my game). I'm using thread for this. When i used the WTK 2.2 monitoring tool i noticed that the memory was increasing .....when i clicked the Objects tab i could see the char[],String was increasing. Can anyone please explain me why this is so.
    'cause i'm not storing any values in variables while running the thread .If that is the case how come the memory increases ?.

    2. [MIDP 1]
    I get an error "Unable to run application" when i try to run my game in 7210. This error is shown only when i select certain options.What might be causing this ?.
    (the game works fine on Java,Nokia emulators)

    Thank you in advance!

  2. #2
    Super Contributor
    Join Date
    Apr 2003
    Location
    USA, CA
    Posts
    7,191

    Re: Increasing memory problem & "Unable to run application" error

    1) depends on what you are doing in your code...

    2) what options do you mean? 7210 is a MIDP 1 device, are you using MIDP 1 methods and classes only?

    Hartti

  3. #3
    Super Contributor
    Join Date
    Mar 2003
    Location
    Israel
    Posts
    2,280

    Re: Increasing memory problem & "Unable to run application" error

    "Unable to run application" is most commonly seen when you run out of heap memory (the 7210 has around 200KB).

    shmoove

  4. #4
    Registered User
    Join Date
    Apr 2007
    Posts
    35

    Question Re: Increasing memory problem & "Unable to run application" error

    Thanx for the reply !
    I checked the memory, it consumes less than 50k. what i'm trying to do is display a canvas for "about us". I'm unable to find the fault as the no error msg is shown in emulators (it runs smoothly).
    The code is shown below, pls tell me where i have made the mistake.

    //pack declaration done

    import javax.microedition.lcdui.*;
    import com.nokia.mid.ui.FullCanvas;


    public class AboutUs
    extends FullCanvas
    implements CommandListener {

    Image image_splash = null;
    Image img_back = null;
    int width = getWidth();
    int height = getHeight();

    public static final Class[] optionClass = {
    getClass("chicken_x.OptionSelection")
    };

    /** Constructor */
    public AboutUs() {
    try {
    jbInit();
    }
    catch (Exception e) {
    e.printStackTrace();
    }
    }

    /**Component initialization*/
    private void jbInit() throws Exception {
    String language = "";
    if (ChickLogic.english) {
    language = "ENG";
    }
    else if (! (ChickLogic.english)) {
    language = "SIN";
    }

    image_splash = Image.createImage("/image/about.png");
    img_back = Image.createImage("/image/" + language + "_BACK.png");
    System.gc();
    }

    /**Handle command events*/
    public void commandAction(Command command, Displayable displayable) {
    /** @todo Add command handling code */
    }

    public void keyPressed(int keyCode) {
    if (keyCode == ( -7)) {
    showMainMenu();
    }

    if (getGameAction(keyCode) == LEFT) {
    }
    if (getGameAction(keyCode) == RIGHT) {
    }
    if (getGameAction(keyCode) == UP) {
    }
    if (getGameAction(keyCode) == DOWN) {
    }
    if (getGameAction(keyCode) == FIRE) {
    showMainMenu();
    }
    repaint();
    }

    public static Class getClass(String className) {
    Class requestedClass = null;
    try {
    requestedClass = Class.forName(className);
    }
    catch (ClassNotFoundException e) {
    System.out.println("Class Not found " + e);
    }
    return requestedClass;
    }

    public void showMainMenu() {
    try {
    Displayable canvas = (Displayable) optionClass[0].newInstance();
    Display.getDisplay(chicken_x.MainMIDlet.instance).setCurrent(canvas);
    }
    catch (IllegalAccessException ex) {
    System.out.println("Key Pressed Illegal Access " + ex);
    }
    catch (InstantiationException ex) {
    System.out.println("Key Pressed Instantiation " + ex);
    }
    }

    /** Required paint implementation */
    protected void paint(Graphics g) {
    /** @todo Add paint codes */
    g.setColor(57, 57, 57);
    g.fillRect(0, 0, 208, 208);
    g.drawImage(image_splash, (width / 2), (height / 2),
    Graphics.HCENTER | Graphics.VCENTER);
    //BACK
    g.drawImage(img_back, (width - 70), 128 - 18,
    Graphics.LEFT | Graphics.TOP);
    }

    }

  5. #5
    Regular Contributor
    Join Date
    May 2003
    Posts
    151

    Re: Increasing memory problem & "Unable to run application" error

    Displayable canvas = (Displayable) optionClass[0].newInstance();
    It appears you have multiple classes and objects which are Canvases.

    This is bad.

    Each one takes up 128x128x4 = 64k of ram - even when they're not the canvas being displayed.

    when i clicked the Objects tab i could see the char[],String was increasing. Can anyone please explain me why this is so.
    Whenever you manipulate a String (e.g. System.out.println("hello" + " world") a new String will be made - this is normal behaviour. The GC will only garbage collect them when the device is low on memory, and then they will start increasing again.

  6. #6
    Regular Contributor
    Join Date
    Aug 2006
    Location
    Rawalpindi, Pakistan
    Posts
    486

    Re: Increasing memory problem & "Unable to run application" error

    Danack is write.canvas is pretty hard on memory. u need to think about optimizing ur code somehow.
    Regards
    Nouman

  7. #7
    Registered User
    Join Date
    Apr 2007
    Posts
    35

    Re: Increasing memory problem & "Unable to run application" error

    Thank you Guys !

    The problem was with the Memory.
    When i reduced the capacity of the Image It works fine.

Similar Threads

  1. XMl Parser Implementation for Symbian
    By ittiam in forum Symbian
    Replies: 26
    Last Post: 2009-09-16, 05:26
  2. i cant build helloworld project
    By akhin in forum Carbide.c++ IDE and plug-ins (Closed)
    Replies: 2
    Last Post: 2008-12-22, 12:38
  3. carbidec++ helloworld project problem
    By akhin in forum Carbide.c++ IDE and plug-ins (Closed)
    Replies: 0
    Last Post: 2007-03-11, 12:40
  4. Replies: 0
    Last Post: 2002-09-24, 13:11
  5. can not successfully link any sample using .NET
    By lobotomat in forum Symbian Tools & SDKs
    Replies: 2
    Last Post: 2002-08-20, 00:29

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×