Using StringItem as a placeholder in J2ME: OutOfMemory error on k750
March 21, 2008
I’ve been using the following:
stringItem = new StringItem(null,null, Item.PLAIN);
to indicate a placeholder for a string in a form on a J2ME application, debugged using the Wireless Toolkit emulator provided with NetBeans. This is perfectly valid w.r.t the stringitem API.
All was fine until deploying it onto an actual device, namely a SE k750, where I was getting spurious OutOfMemory exceptions. Debugging and stepping through the code, it seemed when you tried to apply a label or text to the placeholder stringItem using setText() or setLabel(), you got an OutOfMemory exception. So instead I used:
stringItem = new StringItem(null,"", Item.PLAIN);
and the problem seems to have disappeared. Not sure why this is the case, but I thought I’d post it for future reference!