Results 1 to 9 of 9
Like Tree1Likes
  • 1 Post By lovelesh

Thread: Reduce desktop application memory

  1. #1
    major is offline Member
    Join Date
    Jun 2011
    Posts
    12
    Rep Power
    0

    Question Reduce desktop application memory

    I'm developing a windows desktop (standalone) application which runs as an endless loop.
    Once the application starts, a database connection is created (java.sql.Connection) and is used all over the application.
    The loop does the following operations:
    * Call web services
    * Execute Sql queries to read data from Database
    * Write image (downloaded by one of the web services) to disk. (approximately ~80KB)

    My application takes about 50 MB memory.
    How can I reduce my application memory usage?

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,309
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by major View Post
    My application takes about 50 MB memory.
    How can I reduce my application memory usage?
    Why? An ordinary desktop has +- 1.5GB available for a user process; your process uses about 3 % of it ...

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    lovelesh is offline Senior Member
    Join Date
    Nov 2010
    Location
    Delhi
    Posts
    135
    Blog Entries
    1
    Rep Power
    0

    Smile

    My application takes about 50 MB memory.
    How can I reduce my application memory usage?
    Its near to impossible to tell how to reduce the memory without looking at the code. A proper review would be required to tell something.

    However, make sure you are:
    1. creating objects only at the point of their requirement.
    2. finalizing the objects as soon as their need ends.
    3. handling writer objects properly.

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,188
    Rep Power
    19

    Default

    2. finalizing the objects as soon as their need ends.
    What?

    db

  5. #5
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,755
    Rep Power
    19

    Default

    Quote Originally Posted by major View Post
    I'm developing a windows desktop (standalone) application which runs as an endless loop.
    Once the application starts, a database connection is created (java.sql.Connection) and is used all over the application.
    The loop does the following operations:
    * Call web services
    * Execute Sql queries to read data from Database
    * Write image (downloaded by one of the web services) to disk. (approximately ~80KB)

    My application takes about 50 MB memory.
    How can I reduce my application memory usage?
    As Jos says, this is a pretty small app anyway.
    But that aside, shrink Xmx to the amount you want your app to fit in (something we cannot say, but you appear to have a size requirement). See if it crashes. Take a heap dump on an OOM exception and analyse it to see what was using the memory at the time of the crash. See if you can somehow reduce that. if not then you'll need a larger memory footprint.

  6. #6
    lovelesh is offline Senior Member
    Join Date
    Nov 2010
    Location
    Delhi
    Posts
    135
    Blog Entries
    1
    Rep Power
    0

    Post

    Quote Originally Posted by DarrylBurke View Post
    What?

    db
    I mean nullify the reference variables so that referenced objects become candidates for garbage collection.

  7. #7
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,188
    Rep Power
    19

    Default

    If variables are declared in the correct scope, it's virtually never needed to null them explicitly.

    db

  8. #8
    lovelesh is offline Senior Member
    Join Date
    Nov 2010
    Location
    Delhi
    Posts
    135
    Blog Entries
    1
    Rep Power
    0

    Default

    Quote Originally Posted by DarrylBurke View Post
    If variables are declared in the correct scope, it's virtually never needed to null them explicitly.

    db
    I completely agree to this.
    DarrylBurke likes this.

  9. #9
    major is offline Member
    Join Date
    Jun 2011
    Posts
    12
    Rep Power
    0

Similar Threads

  1. Datasource in desktop application
    By Manolo in forum Advanced Java
    Replies: 4
    Last Post: 04-28-2011, 07:29 AM
  2. Desktop Application
    By vineet osho in forum New To Java
    Replies: 3
    Last Post: 06-13-2010, 05:37 AM
  3. Remote Desktop Application
    By Drango in forum CLDC and MIDP
    Replies: 2
    Last Post: 05-17-2010, 11:22 PM
  4. Replies: 3
    Last Post: 12-04-2009, 12:10 PM
  5. How to reduce the size or avoiding out of memory error?
    By rajeshkumarmsc in forum Advanced Java
    Replies: 3
    Last Post: 08-11-2007, 10:15 PM

Posting Permissions

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