Shop OBEX P1 Docs P2 Docs Learn Events
polling — Parallax Forums

polling

AleksAleks Posts: 52
edited 2008-03-18 19:56 in General Discussion
I've been working on a Javelin project that requires polling a flash memory until it stumbles across a change in the data. However I keep running into a out of memory error. I was wondering if anyone could supply me with a javelin polling program that won't render the out of memory error?

Comments

  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2008-03-05 21:12
    If you are using System.out.print("some text" + number),
    or in general add strings or use the new keyword in a loop, you will keep
    getting those errors.

    Post your program so we can see what causes the error.

    regards peter
  • HueyHuey Posts: 23
    edited 2008-03-05 21:53
    From my experience when i get an OutOfMemory error i usually find something like this in my code

    do{

    · String newStringObject = someObject.toString();

    }while(!someObjectArray.isEmpty());

    what happens is that each time there is a loop it creates a whole new instance of the variable, which sucks up memory.· An easy fix for the example above would be something like:

    String theVariable = "";
    do{
    · theVariable = someObject.toString();
    · //do stuff with theVariable
    }while(!someObjectArray.isEmpty());

    this way it uses the same variable over and over again.

    Hope this helps, if not it could be a good hint.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Huey


    Double Bachelor of Science
    CPET - Computer Engineering Technologies
    CIS - Computer Information Systems
    MSU-Northern
    Chair of MSU-Northern IEEE Student Branch
  • AleksAleks Posts: 52
    edited 2008-03-06 18:20
    ok well here's my main program, as well as an additional folder of library files.
  • AleksAleks Posts: 52
    edited 2008-03-18 19:56
    Ok so I found the problem. It seems that when anything is declared static it becomes a registered variable, not prone to change. So when I went through and declared my library files, each subroutine within them was declared static. This poses a problem in that every time the subroutine is called it recreates the used variables. Obviously thats a problem.
Sign In or Register to comment.