Results 1 to 13 of 13
  1. #1
    davetheant is offline Member
    Join Date
    Sep 2010
    Posts
    47
    Rep Power
    0

    Default Questions about java JVM

    Hello everyone. I have some questions about the JVM in Java. Is there any way to permanently increase it without having to run my code from the command prompt every time? If so, how? And this may be dumb but could I allot free hard drive space to the JVM (sort of like Paging in Windows)? Thanks.

  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

  3. #3
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by Eranga View Post
    Permanently increase what? I didn't get you.
    I think he means increase heap memory.

  4. #4
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

    Default

    Hmmm, better to mention those stuff clearly next time.

    Anyway, you can change the shell script. For example,

    java -Xms64m -Xmx512m
    where Xms<size> is the initial heap size and Xmx<size> is the maximum heap size.

  5. #5
    davetheant is offline Member
    Join Date
    Sep 2010
    Posts
    47
    Rep Power
    0

    Default

    Sorry, I meant the memory. And that code is what I meant by launching from command prompt. Or will that permanently change the heap space? I typed something like that with the name of my program (to run it).

  6. #6
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

    Default

    And at the same time, there can be maximum heap size which you can allocate for a single process. Solaris can allocate 2GB without a problem but I'm not sure with MS Windows. As far as I remember Win 2003 can allocate 1.5GB but not with XP.

    In general set the maximum heap is to 1/4 of the total physical memory at the start, and generally you can increase. Set the minimum as 1/2 of the initial maximum heap, and don't change it later.

  7. #7
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

    Default

    Quote Originally Posted by davetheant View Post
    Sorry, I meant the memory. And that code is what I meant by launching from command prompt. Or will that permanently change the heap space? I typed something like that with the name of my program (to run it).
    You mean the total memory used in your application, when running?

  8. #8
    quad64bit's Avatar
    quad64bit is offline Moderator
    Join Date
    Jul 2009
    Location
    VA
    Posts
    1,323
    Rep Power
    7

    Default

    You could make a 'launcher' class that launches a new jvm instance with the correct flags. For instance, class Launcher might have a main method that executes a native command, in this case something like "java -Xmx1024m MyApp". MyApp would also have a main method. The launcher terminates as soon as it launches the second app. Some of the old IDEs were launched in this way.

  9. #9
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

  10. #10
    quad64bit's Avatar
    quad64bit is offline Moderator
    Join Date
    Jul 2009
    Location
    VA
    Posts
    1,323
    Rep Power
    7

    Default

    You may be correct, I interpreted the statement
    Is there any way to permanently increase it without having to run my code from the command prompt every time?
    to mean 'Is there a way I don't have to type the memory arguments in every time from the command line'. A launcher would be one way to do that.

  11. #11
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

    Default

    Quote Originally Posted by quad64bit View Post
    You may be correct, I interpreted the statement ...
    Actually what I mean is that I'm not clear with what OP really talking about, either heap memory as it is, or just looking at the memory utilization in his application/code.

  12. #12
    quad64bit's Avatar
    quad64bit is offline Moderator
    Join Date
    Jul 2009
    Location
    VA
    Posts
    1,323
    Rep Power
    7

    Default

    Agreed! Maybe OP can clarify? Please? :D

  13. #13
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

Similar Threads

  1. Some Java questions
    By vegetable69 in forum New To Java
    Replies: 1
    Last Post: 11-29-2010, 01:47 PM
  2. JAVA questions
    By melody in forum New To Java
    Replies: 0
    Last Post: 10-29-2009, 12:07 AM
  3. Pls i need help with these 2 Java Questions
    By jyde in forum Advanced Java
    Replies: 2
    Last Post: 10-19-2008, 08:33 PM
  4. Few Questions about java
    By Grom in forum NetBeans
    Replies: 11
    Last Post: 09-13-2008, 03:26 PM

Tags for this Thread

Posting Permissions

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