Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
JamesColeman
Posts: 266
Registered: ‎04-24-2009
My Device: Not Specified
Accepted Solution

Virtual Keyboard causes OutOfMemoryError

JDE 4.7

I have NO IDEA what is going on.  Everything was working great, I changed some custom bitmap buttons, now any screen that has an EditField crashes when the virtual keyboard comes up or shortly after when I start typing text in the edit field, or sometimes when I hide the keyboard.

 

Uncaught exception thrown - OutOfMemoryError

Everything else in the program works fine.

I can not understand the Calling Method information enough to locate the problem but bitmap is on the first line, so I would assume it has something to do with my buttons I changed.  But what would they have to do with an editField and the virtualkeyboard?

Screen Shot


Any thoughts would be appreciated.

Please use plain text.
Developer
JamesColeman
Posts: 266
Registered: ‎04-24-2009
My Device: Not Specified

Re: Virtual Keyboard causes OutOfMemoryError

More information.

 

I can start the program show the keyboard, hide the keyboard, and then any button I push also causes a Uncaught exception thrown - OutOfMemoryError.  If I never show the keyboard, everything works.

Please use plain text.
Developer
JamesColeman
Posts: 266
Registered: ‎04-24-2009
My Device: Not Specified

Re: Virtual Keyboard causes OutOfMemoryError

I'm still working on this one.

 

If I view the memory statistics everything looks fine until I start a keyboard.

 

To keep it simple, I started the program, checked the memory, used the menu key to display the keyboard and hide the keyboard.  The RAM lost -1283588 and FLASH lost -1547524 after displaying and hiding the keyboard.  I hit another button and got theOutOfMemoryError.

 

I'm still not sure what to do.  I didn't write the keyboard code.

 

If someone could point me in the right diection, I would appreciate it.

 

Thanks!

Please use plain text.
Developer
RexDoug
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: Virtual Keyboard causes OutOfMemoryError

Sounds to me like displaying the keyboard is causing a sublayout, and this is getting into some type of endless loop, consuming system resources. I can pretty-much guarentee that the keyboard popup didn't eat 1.2MB of RAM and 1.5MB of flash.

 

Look very closely at layout() or sublayout() overrides.

 

 

 

Please use plain text.
Developer
JamesColeman
Posts: 266
Registered: ‎04-24-2009
My Device: Not Specified

Re: Virtual Keyboard causes OutOfMemoryError

Hi REXDOUG;

 

I made it quite a few months without needing any help, but I seem have had some bad Karma lately.  I have several issues I

am working on right now.

 

I think this one is solved though.  Your suggestion of "Look very closely at layout() or sublayout() overrides." sent me in the right direction.  I haven't quite got it wokring yet, but at least I kow where the problem is.

 

I have learned more too.

 

THANKS!!!!!

Please use plain text.
Developer
JamesColeman
Posts: 266
Registered: ‎04-24-2009
My Device: Not Specified

Re: Virtual Keyboard causes OutOfMemoryError

I have been working on this for quite a while. And while I have learned a lot, but I still have the OutOfMemoryError with the Virtual Keyboard. It sure seems that REXDOUG is correct in that it is in the layout() or sublayout() overrides when the keyboard moves the screen.

I commented out most of my code and I'm wondering if the problem is in my approach and I have done something "illegal". I have a complex popup screen that seemed like a nightmare to accomplish with vertical and horizontal managers, so I set it up as a Manager and used sublayout to layout my button fields.

I have tried the following with and without the getPreferredWidth and getPreferredHeight and super.sublayout

class MenuScreenManager extends Manager
{
MenuScreenManager()
{
super(Manager.VERTICAL_SCROLL | Manager.VERTICAL_SCROLLBAR);
}


protected void sublayout(int width, int height)
{
int XPosition = 0;
int YPosition = 0;
int iNumFields = getFieldCount();

//super.sublayout(width, height);

for(int i=0; i
Please use plain text.
Developer
JamesColeman
Posts: 266
Registered: ‎04-24-2009
My Device: Not Specified

Re: Virtual Keyboard causes OutOfMemoryError

something went wrong and all my post didn't show.  I have to take care of somehting then I will repost they above.
Please use plain text.
Developer
JamesColeman
Posts: 266
Registered: ‎04-24-2009
My Device: Not Specified

Re: Virtual Keyboard causes OutOfMemoryError

Let's try again

 

I have been working on this for quite a while. And while I have learned a lot, but I still have the OutOfMemoryError with the Virtual Keyboard. It sure seems that REXDOUG is correct in that it is in the layout() or sublayout() overrides when the keyboard moves the screen.  However, I'm not seeing it.

I commented out most of my code and I'm wondering if the problem is in my approach and I have done something "illegal". I have a complex popup screen that seemed like a nightmare to accomplish with vertical and horizontal managers, so I set it up as a Manager and used sublayout to layout my button fields. I simplified the layout code in the example just to keep it breif.

 

I have tried the following with and without the getPreferredWidth and getPreferredHeight and super.sublayout.. the Manager.VERTICAL_SCROLL | Manager.VERTICAL_SCROLLBAR are also something I was playing with.

class MenuScreenManager extends Manager
{
MenuScreenManager()
{
super(Manager.VERTICAL_SCROLL | Manager.VERTICAL_SCROLLBAR);
}


protected void sublayout(int width, int height)
{
int XPosition = 0;
int YPosition = 0;
int iNumFields = getFieldCount();

//super.sublayout(width, height);

for(int i=0; i<iNumFields; i++)
        {
            Field field = this.getField(i);
            layoutChild(field,48,48);
            setPositionChild(field,XPosition,YPosition);
            XPosition = XPosition + 48;
        }
        setExtent (480, 48);
        //setPosition (0, 0);
        setPosition (0, 312);
    }
   
  /* public int getPreferredWidth()
   {
       return 480;
   }
   public int getPreferredHeight()
   {
       return 48;
   }*/
   
}

 

I also experimented with adding a sublayout from the screen itself.

 

/*  protected void sublayout(int width, int height)
    {
        super.sublayout(width, height);
        //setExtent (480, 48);
        //setPosition (0,312);
       
    }*/

 

I also use custom button fields so the problem might be there, but I wouldn't think the problem would be with the button.  There isn't much to that code.

 

Any thoughts would be appreciated.

Please use plain text.
Developer
Developer
CMY
Posts: 1,122
Registered: ‎02-10-2009
My Device: 8130 / 8350 / 9530 / 9550 / 9850 / PlayBook
My Carrier: Verizon

Re: Virtual Keyboard causes OutOfMemoryError

[ Edited ]
I think your  problem may be that you are displaying you screen at y position 312, which means it is hid by the keyboard so it is probabaly continuously calling sublayout because it has to move you screen within the viewable area since one of the buttons has focus. Just a thought.
Message Edited by CMY on 09-18-2009 09:09 PM
Please use plain text.
Developer
JamesColeman
Posts: 266
Registered: ‎04-24-2009
My Device: Not Specified

Re: Virtual Keyboard causes OutOfMemoryError

That sure sounds like it could be the problem.  I'll check into it and update the post when I'm done experimenting.

 

Thanks!

Please use plain text.