×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Mar 2012
    Posts
    2

    out of memory exception

    I am trying to read a 2mb file into a memory and then send that file to web server. But I am getting out of memory exception

    Code:
      FileConnection fileConn = (FileConnection)Connector.open("file:///" + pictureURI.getString(), Connector.READ);
         InputStream fis = fileConn.openInputStream();
         long overallSize = fileConn.fileSize();
    
         int chunkSize = 2048;
         int length = 0;
         while (length < overallSize)
         {
    
            byte[] data = new byte[chunkSize];
            int readAmount = fis.read(data, 0, chunkSize);
            byte[] newImageData = new byte[rawImage.length + chunkSize];
            System.arraycopy(rawImage, 0, newImageData, 0, length);
            System.arraycopy(data, 0, newImageData, length, readAmount);
            rawImage = newImageData;
            length += readAmount;
    
         }
           fis.close();
            fileConn.close();
    500kb files are uploading. What could be the reason? Please shed a light on this.

    I tried this also in loop but no use, System.gc();

    Thanks in advance.

  2. #2
    Nokia Developer Expert
    Join Date
    Aug 2007
    Posts
    1,595

    Re: out of memory exception

    Hello tvgece,

    and welcome to Nokia Developer Discussion Boards!

    A question to start with, which device are you using for your application?

    Also, does this happen only during uploading? What about without uploading?

    Also you might want to check this article on memory usage for images on Nokia Developer Wiki: http://www.developer.nokia.com/Commu...y_Usage_Images

    Regards,
    r2j7
    [URL="http://library.forum.nokia.com/java"][B] >>> Java Developer's Library <<<[/B][/URL]
    [URL="https://www.developer.nokia.com/Resources/Support/Technical_support.xhtml"] [B]>>> Technical Support for Java ME development <<<[/B][/URL]
    [URL="https://publish.ovi.com/info/"][B]>>> Nokia Publish: reach millions of Nokia users worldwide through Nokia Store <<<[/B][/URL]

  3. #3
    Registered User
    Join Date
    Mar 2012
    Posts
    2

    Re: out of memory exception

    Hi,

    I am using Nokia X2-01(s40).

    I tried different methods, loading the file in to memory and then sent those data. (loading into memory worked), but when I initiated the upload process, it giving error.

    Then I tried fetching 1024 bytes into a buffer and sent those, repeated till the end of file, but its still giving same error after 60% of the upload.

    Is there any limit for uploading in this device? or any memory limit?

    Thanks in advance

  4. #4
    Nokia Developer Expert
    Join Date
    Aug 2007
    Posts
    1,595

    Re: out of memory exception

    Hello tvgece,

    Nokia X2-01 has heap limitation of 2 MB which sets limitations on how much memory is available for MIDlet to handle runtime operations: when too much memory is used during operation than there is available in the heap then that usually leads to the outcome which you are experiencing.

    Can you try running the application on a Series 40 SDK emulator and monitor the memory consumption via Diagnostics window in order to see what happens in the application when this happens?

    Regards,
    r2j7
    [URL="http://library.forum.nokia.com/java"][B] >>> Java Developer's Library <<<[/B][/URL]
    [URL="https://www.developer.nokia.com/Resources/Support/Technical_support.xhtml"] [B]>>> Technical Support for Java ME development <<<[/B][/URL]
    [URL="https://publish.ovi.com/info/"][B]>>> Nokia Publish: reach millions of Nokia users worldwide through Nokia Store <<<[/B][/URL]

Similar Threads

  1. Out of Memory Exception in
    By honest_success in forum Mobile Java Media (Graphics & Sounds)
    Replies: 8
    Last Post: 2009-09-10, 20:14
  2. memory out exception
    By knawaz in forum Mobile Java General
    Replies: 6
    Last Post: 2008-07-18, 06:29
  3. Out of Memory Exception
    By rakesh.pachawa in forum Mobile Java Networking & Messaging & Security
    Replies: 0
    Last Post: 2007-12-08, 12:49
  4. out of memory exception while loading an svg
    By shydisturbedboy in forum Mobile Java General
    Replies: 0
    Last Post: 2007-09-24, 05:15
  5. memory full exception
    By aju_nokia in forum Mobile Java General
    Replies: 2
    Last Post: 2006-12-19, 13:24

Posting Permissions

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