×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Apr 2005
    Posts
    1

    3650: Parsing data-file crashes application

    Hello everybody.

    I'm developing a MIDlet for series 60 phones that needs to parse a quite large (~280k) binary data-file that comes with the .jar-file.

    I access the file by creating a DataInputStream reader = new DataInputStream(getClass().getRessourceAsStream(filename)), and doing reader.readByte(), reader.readBoolean() .. to parse the data.

    This takes some seconds for the whole file, and works fine. The problem is that the parsing has do be done several times, and when it does for the 5th or 6th time the application terminates with an error message:
    "App. closed.
    Main"

    Does anyone know a solution for this one ?

  2. #2
    Regular Contributor
    Join Date
    Aug 2003
    Location
    uk
    Posts
    232
    two things:

    If you are creating images each time, then you are leaking memory each time and as the 3650 has less heap than other nokia series 60 phones it will run out of memory first.

    Also, when you open the stream it actually copies the whole file into the heap, but you still have to read it to get at it, so as you read it, you affectively have the file in the heap twice (until you close the stream).

  3. #3
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395
    If your problem is happening on MIDP1 S60s, and not on MIDP2 60s, then I think it is caused by a bug in those devices, where getResourceAsStream() results in a memory leak. Several opens on a file that size will bleed you dry of memory.

    On MIDP1 Series 60 phones, read resources only once, never read them again. (This goes also for images and sounds).

    Cheers,
    Graham.

Posting Permissions

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