×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Oct 2009
    Location
    Russia, Yaroslavl region
    Posts
    6

    Out of Memory Error

    I am wrote simple code that doing http transfering array of byte.
    When i transfering array smaller than 400 kB to the web server it is succesfull ending (i see transfered file on site).
    But when i am trying to transfer 700 kB there appear error on (NOKIA 6233) display with message.

    "Out of Memory Error
    java/lang/OutOfMemoryError"
    So, where is memory overloading occurs? And exactly with array sized more then 400 kB.
    Is it RAM memory overloading?

    Beforehand for answers.

    Some of my code:

    OutputStream os = null;
    os = hc.openDataOutputStream();
    os.write(DataArray);

  2. #2
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: Out of Memory Error

    The Nokia 6233 has 2Mb of heap, and that's your limit. When you run out of that, you get an OutOfMemoryException.

    When you write to an HttpConnection, everything you write is buffered, so when you write 700k to the OutputStream, you consume at least 700k of memory. Assuming you have the 700k in an array, you're then using 1.4Mb. Plus whatever else your application is using (code + data).

    This is a common problem when sending data to HTTP servers, especially on Series 40s, which are relatively constrained on memory compared to Series 60s.

    Instead of loading the data into the array, then writing the array, you could send it directly to the HttpConnection. This should double the amount you can write before you run out of memory. Make sure you release any other objects you no longer require.

    Graham.

  3. #3
    Registered User
    Join Date
    Oct 2009
    Location
    Russia, Yaroslavl region
    Posts
    6

    Re: Out of Memory Error

    Thanks, i am understood. But may i relieve memory by using flush()?
    I red that "Flushes this output stream and forces any buffered output bytes to be written out."
    If i will using flush() after specific bytes count for relieving buffer and therefore memory.

  4. #4
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: Out of Memory Error

    I'm afraid not. In most implementations, you are basically writing to a ByteArrayOutputStream. The buffered data will be sent to the server only when the connection is made, which is usually when you call openInputStream() or getResponseCode(). Flushing... is generally a bad plan. You might find that you can't send any more data afterwards.

    Graham.

Similar Threads

  1. [newbie here] Link error
    By xitpu in forum Symbian
    Replies: 3
    Last Post: 2007-01-24, 16:53
  2. carbide build problem help please
    By berkcekisbas in forum Carbide.c++ IDE and plug-ins (Closed)
    Replies: 1
    Last Post: 2006-09-26, 19:41
  3. problem with Code Warrior 5.2
    By mayankkedia in forum Symbian
    Replies: 4
    Last Post: 2006-06-22, 08:26
  4. problem with codewarrior 5.2
    By mayankkedia in forum Symbian Tools & SDKs
    Replies: 3
    Last Post: 2004-09-27, 16:08
  5. camera app compilation problems
    By basarim in forum Symbian Tools & SDKs
    Replies: 1
    Last Post: 2003-12-31, 18:16

Posting Permissions

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