Shop OBEX P1 Docs P2 Docs Learn Events
OutOfMemoryError! — Parallax Forums

OutOfMemoryError!

eshieheshieh Posts: 5
edited 2004-09-07 21:16 in General Discussion
· I get this error:
[noparse][[/noparse]Error IDE-0028] Unhandled exception in JVM: java.lang.OutOfMemoryError
Exception thrown in file 'C:\Program Files\Parallax Inc\Javelin Stamp IDE\lib\java\lang\Exception.java' at line 10

The program I have, is for a GPS which is hooked up to the javelin stamp.· I am reading the data in from the GPS and then sending it to a computer, via rs485 protocol.· So when running this program, I get the error mentioned above.· I'm thinking that it's something to do with the buffer or something, and I was wondering if you knew of any command to maybe clear the buffer or something?· I've attached the code to my program.· Let me know if you have questions about it or suggestions to try.· Thanks a bunch for your help!

Comments

  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2004-09-07 19:50
    I think it goes wrong here:

    ····· while (i<3) {
    ··· //while (false) {
    ····· //System.out.print(rsiuart.byteAvailable());
    ······· if (rsiuart.byteAvailable()) {
    ········· c=(char) (rsiuart.receiveByte());
    ········· //System.out.print((int)c);
    ········· //if (c != 0) {
    ··········· System.out.println("char: "+(int)c);
    ··········· i++;
    ········· //}
    ······· }
    ····· }
    ····· CPU.delay(4000);
    ····· CPU.writePin(flowi,true);
    ····· txiuart.sendString("<GPS>"+buffer.toString()+"</GPS> ");
    ····· CPU.writePin(flowi,false);
    ····· }
    The above·code will continually execute this line
    ····· txiuart.sendString("<GPS>"+buffer.toString()+"</GPS> ");
    The use of + to concatenate strings will result in the creation
    of temporary strings. As there is no garbage collection it is a matter
    of time until you get the out of memory error.
    Try to assemble a complete string in a StringBuffer and then use
    that buffer to send or print.

    regards peter
    ·
  • eshieheshieh Posts: 5
    edited 2004-09-07 21:16
    Thanks a lot for your helpful/quick reply! smile.gif
Sign In or Register to comment.