Getting physical memory

Discussion in 'Java' started by Chris, Jun 7, 2004.

  1. Chris

    Chris Guest

    Is it possible to know how much physical memory there is in a machine?

    Runtime.getRuntime().totalMemory() returns the amount available to the JVM,
    not the amount in a machine.
    Chris, Jun 7, 2004
    #1
    1. Advertising

  2. Chris

    Liz Guest

    the dos command "mem" should do it
    call it via NJI


    "Chris" <> wrote in message
    news:40c4df7a$...
    > Is it possible to know how much physical memory there is in a machine?
    >
    > Runtime.getRuntime().totalMemory() returns the amount available to the

    JVM,
    > not the amount in a machine.
    >
    >
    Liz, Jun 8, 2004
    #2
    1. Advertising

  3. "Liz" <> wrote in message news:<Xb8xc.957$ar.377@attbi_s04>...
    > the dos command "mem" should do it
    > call it via NJI


    "mem" only reports the memory available to DOS programs (for example
    my 2k machine reports 1 MB of RAM). There are much better functions to
    use in the Win32 API. Besides, the OP didn't write that he uses a
    Windows machine.

    > "Chris" <> wrote in message
    > news:40c4df7a$...
    > > Is it possible to know how much physical memory there is in a machine?
    > >
    > > Runtime.getRuntime().totalMemory() returns the amount available to the

    > JVM,
    > > not the amount in a machine.


    There is no way to tell the amount of physical memory in pure Java.
    Why do you need that information?

    /Jesper Nordenberg
    Jesper Nordenberg, Jun 8, 2004
    #3
  4. Chris

    Roedy Green Guest

    On 8 Jun 2004 04:16:21 -0700, (Jesper Nordenberg)
    wrote or quoted :

    >"mem" only reports the memory available to DOS programs (for example
    >my 2k machine reports 1 MB of RAM). There are much better functions to
    >use in the Win32 API. Besides, the OP didn't write that he uses a
    >Windows machine.


    If you can find any console mode app to tell you, exec it and capture
    the result. See http://mindprod.com/jgloss/exec.html

    --
    Canadian Mind Products, Roedy Green.
    Coaching, problem solving, economical contract programming.
    See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
    Roedy Green, Jun 8, 2004
    #4
  5. Chris

    Roedy Green Guest

    On 8 Jun 2004 04:16:21 -0700, (Jesper Nordenberg)
    wrote or quoted :

    >"mem" only reports the memory available to DOS programs (for example
    >my 2k machine reports 1 MB of RAM). There are much better functions to
    >use in the Win32 API. Besides, the OP didn't write that he uses a
    >Windows machine.


    If you can find a WinApi call to tell you want you want, you can write
    a tiny bit of JNI to get at it.
    http://mindprod.com/jgloss/jni.html

    See http://mindprod.com/products.html#PENTIUM for some sample JNI code
    you could use as a model.

    It might be part of the JConfig library. See
    http://mindprod.com/jgloss/jconfig.html

    --
    Canadian Mind Products, Roedy Green.
    Coaching, problem solving, economical contract programming.
    See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
    Roedy Green, Jun 8, 2004
    #5
  6. Chris

    Liz Guest

    "Roedy Green" <> wrote in message
    news:...
    > On 8 Jun 2004 04:16:21 -0700, (Jesper Nordenberg)
    > wrote or quoted :
    >
    > >"mem" only reports the memory available to DOS programs (for example
    > >my 2k machine reports 1 MB of RAM). There are much better functions to
    > >use in the Win32 API. Besides, the OP didn't write that he uses a
    > >Windows machine.

    >
    > If you can find a WinApi call to tell you want you want, you can write
    > a tiny bit of JNI to get at it.
    > http://mindprod.com/jgloss/jni.html
    >
    > See http://mindprod.com/products.html#PENTIUM for some sample JNI code
    > you could use as a model.
    >
    > It might be part of the JConfig library. See
    > http://mindprod.com/jgloss/jconfig.html
    >
    > --
    > Canadian Mind Products, Roedy Green.
    > Coaching, problem solving, economical contract programming.
    > See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.


    Ok, then figure out what the memory is using whatever and
    provide it to the program via -D on the command line. The
    program can get it through properties.

    java -DMEMORY=55 myjavaprog
    Liz, Jun 8, 2004
    #6
  7. Chris

    Corey Brown Guest

    "Liz" <> wrote in message news:tNkxc.68247$Ly.49695@attbi_s01...
    >
    > "Roedy Green" <> wrote in message
    > news:...
    > > On 8 Jun 2004 04:16:21 -0700, (Jesper Nordenberg)
    > > wrote or quoted :
    > >
    > > >"mem" only reports the memory available to DOS programs (for example
    > > >my 2k machine reports 1 MB of RAM). There are much better functions to
    > > >use in the Win32 API. Besides, the OP didn't write that he uses a
    > > >Windows machine.

    > >
    >> [ SNIP ]
    >>
    > > >

    > Ok, then figure out what the memory is using whatever and
    > provide it to the program via -D on the command line. The
    > program can get it through properties.
    >
    > java -DMEMORY=55 myjavaprog


    And if the Java program is long lived, then what?

    >
    >
    Corey Brown, Jun 8, 2004
    #7
  8. Chris

    Liz Guest

    "Corey Brown" <> wrote in message
    news:Z_lxc.123$...
    >
    > "Liz" <> wrote in message

    news:tNkxc.68247$Ly.49695@attbi_s01...
    > >
    > > "Roedy Green" <> wrote in message
    > > news:...
    > > > On 8 Jun 2004 04:16:21 -0700, (Jesper Nordenberg)
    > > > wrote or quoted :
    > > >
    > > > >"mem" only reports the memory available to DOS programs (for example
    > > > >my 2k machine reports 1 MB of RAM). There are much better functions

    to
    > > > >use in the Win32 API. Besides, the OP didn't write that he uses a
    > > > >Windows machine.
    > > >
    > >> [ SNIP ]
    > >>
    > > > >

    > > Ok, then figure out what the memory is using whatever and
    > > provide it to the program via -D on the command line. The
    > > program can get it through properties.
    > >
    > > java -DMEMORY=55 myjavaprog

    >
    > And if the Java program is long lived, then what?


    What is your question?
    Liz, Jun 8, 2004
    #8
  9. Chris

    Chris Guest

    "Jesper Nordenberg" <> wrote in message
    news:...

    <snip>

    > There is no way to tell the amount of physical memory in pure Java.
    > Why do you need that information?


    Because I want to use NIO's MappedByteBuffer to map files to memory. A
    little experimentation shows that if you map too many files or files that
    are too big you'll get error messages. So I want to know what the limits
    are.
    Chris, Jun 14, 2004
    #9
  10. On Mon, 14 Jun 2004 12:26:08 -0500, Chris wrote:

    > "Jesper Nordenberg" <> wrote in message
    > news:...
    >
    > <snip>
    >
    >> There is no way to tell the amount of physical memory in pure Java.
    >> Why do you need that information?

    >
    > Because I want to use NIO's MappedByteBuffer to map files to memory. A
    > little experimentation shows that if you map too many files or files that
    > are too big you'll get error messages. So I want to know what the limits
    > are.


    You can set the limit.
    Check the Evaluation section of:
    <http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4879883>
    Thomas Schodt, Jun 15, 2004
    #10
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?UmFlZCBTYXdhbGhh?=

    Getting Application Path Physical location

    =?Utf-8?B?UmFlZCBTYXdhbGhh?=, Oct 3, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    2,896
    Mark Monster
    Oct 3, 2005
  2. Bart Nessux

    Get Amount of Physical Memory

    Bart Nessux, May 24, 2004, in forum: Python
    Replies:
    2
    Views:
    320
    Helmut Jarausch
    May 26, 2004
  3. rony_16
    Replies:
    1
    Views:
    825
    Eliyahu Goldin
    Oct 29, 2006
  4. Replies:
    9
    Views:
    2,041
    Arne Vajhøj
    Jul 20, 2009
  5. Replies:
    4
    Views:
    6,708
    Martin Demberger
    Jul 15, 2009
Loading...

Share This Page