×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Aug 2006
    Posts
    3

    Angry Memory usage with UDPDatagramConnection

    Hi,

    I've a problem with memory consumption when using UDPDatagramConnection. I've a server sending messages every 1s and on my MIDP client side I've set up a UDPDatagramConnection to get those messages in a loop. However, everytime I get a new message (i.e every 1s), used memory increases!!
    Shouldn't the receive() method reuse the same datagram to store the newly received data?

    The code look something like :

    UDPDatagramConnection connection = (UDPDatagramConnection) Connector.open(url);
    max = connection.getMaximumLength();
    packet = connection.newDatagram(max);
    while (notDone) {
    connection.receive(receivePacket);
    //some processing
    }

    "connection", "max" and "packet" are globaly defined!

    Thanks for any help to find out the problem.
    M.G.

  2. #2
    Super Contributor
    Join Date
    Dec 2005
    Location
    Europe/Poland/Warsaw
    Posts
    1,697

    Re: Memory usage with UDPDatagramConnection

    hi,

    do you have something like:
    Code:
    //When reading instead of using getData the reset  method must be used.
        datagram = connection.newDatagram(max);
        while (notDone) {
            // The last read in the loop changed the read pointer
            // so reset the pointer.
            datagram.reset();
            datagram.setLength(max);
            connection.receive(datagram);
            message = datagram.readUTF(message);
            // process message ...
        }
    taken from MIDP 2.0 docs,

    regards,
    Peter

  3. #3
    Registered User
    Join Date
    Aug 2006
    Posts
    3

    Re: Memory usage with UDPDatagramConnection

    I'm using the getData() instead of readUTF(), reset() and setLength(max) in a finally block.

    Forget to syat that I'm checking the memory usage using the Nokia S40 SDK 6230i.

    M.G.

  4. #4
    Registered User
    Join Date
    Aug 2006
    Posts
    3

    Re: Memory usage with UDPDatagramConnection

    It seems like the garbage collection is not working anymore when listening to UDP datagrams!! Does a loop avoid garbage collection!!!??

    I'm really stuck and any idea will be of great help.

    Regards
    M.G.

Similar Threads

  1. Array memory usage
    By mcotten in forum Mobile Java General
    Replies: 7
    Last Post: 2008-01-04, 14:45
  2. How to determine Heap memory usage
    By vjramani in forum Mobile Java General
    Replies: 0
    Last Post: 2005-11-16, 06:03
  3. Nokia 7210 HttpConnection error when high memory usage
    By denvall in forum Mobile Java Networking & Messaging & Security
    Replies: 0
    Last Post: 2004-03-12, 12:07
  4. Efficient memory usage tips??
    By cyphre666 in forum Mobile Java Media (Graphics & Sounds)
    Replies: 3
    Last Post: 2003-11-02, 21:02
  5. can not successfully link any sample using .NET
    By lobotomat in forum Symbian Tools & SDKs
    Replies: 2
    Last Post: 2002-08-20, 00:29

Posting Permissions

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