How to determine the Memory size of my computer?

I need to find a way to determine how much computer RAM i have left. I was suggested to use System class methods like "Runtime.getRuntime().getFreeMemory()", and I need to determine how much Memory I need to use when I launch Java VM with Xmx option.
I wonder if there is more detail I need to know at this moment? If this question is more suitable in Java VM forum, please let me know.

This is a slightly messed version of the one in the J2D Demo, use JFrame.add(new MemoryMonitor());
I'm not entirely sure if it'll work straight off since I messed with it but it should, all the memory stuff is hidden away there somewhere even if it won't.
Shish
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
import java.awt.*;
import java.awt.event.*;
import java.awt.image.BufferedImage;
import java.awt.geom.Line2D;
import java.awt.geom.Rectangle2D;
import java.util.Date;
import javax.swing.*;
import javax.swing.border.EtchedBorder;
import javax.swing.border.TitledBorder;
public class MemoryMonitor extends JPanel {
    static JCheckBox dateStampCB = new JCheckBox("Output Date Stamp");
    public Surface surf;
    JPanel controls;
    boolean doControls;
    JTextField tf;
    public MemoryMonitor() {
     note=n;
        setLayout(new BorderLayout());
        setBorder(new TitledBorder(new EtchedBorder(), "Memory Monitor"));
        add(surf = new Surface());
        controls = new JPanel();
        controls.setPreferredSize(new Dimension(135,80));
        Font font = new Font("serif", Font.PLAIN, 10);
        JLabel label = new JLabel("Sample Rate");
        label.setFont(font);
        label.setForeground(Color.black);
        controls.add(label);
        tf = new JTextField("1000");
        tf.setPreferredSize(new Dimension(45,20));
        controls.add(tf);
        controls.add(label = new JLabel("ms"));
        label.setFont(font);
        label.setForeground(Color.black);
        controls.add(dateStampCB);
        dateStampCB.setFont(font);
        addMouseListener(new MouseAdapter() {
            public void mouseClicked(MouseEvent e) {
               removeAll();
               if ((doControls = !doControls)) {
                   surf.stop();
                   add(controls);
               } else {
                   try {
                       surf.sleepAmount = Long.parseLong(tf.getText().trim());
                   } catch (Exception ex) {note.alert(ex);}
                   surf.start();
                   add(surf);
               validate();
               repaint();
    public void start() {
     surf.start();
    public class Surface extends JPanel implements Runnable {
        public Thread thread;
        public long sleepAmount = 1000;
        private int w, h;
        private BufferedImage bimg;
        private Graphics2D big;
        private Font font = new Font("Times New Roman", Font.PLAIN, 11);
        private Runtime r = Runtime.getRuntime();
        private int columnInc;
        private int pts[];
        private int ptNum;
        private int ascent, descent;
        private float freeMemory, totalMemory;
        private Rectangle graphOutlineRect = new Rectangle();
        private Rectangle2D mfRect = new Rectangle2D.Float();
        private Rectangle2D muRect = new Rectangle2D.Float();
        private Line2D graphLine = new Line2D.Float();
        private Color graphColor = new Color(46, 139, 87);
        private Color mfColor = new Color(0, 100, 0);
        private String usedStr;
        public Surface() {
            setBackground(Color.black);
            addMouseListener(new MouseAdapter() {
                public void mouseClicked(MouseEvent e) {
                    if (thread == null) start(); else stop();
        public Dimension getMinimumSize() {
            return getPreferredSize();
        public Dimension getMaximumSize() {
            return getPreferredSize();
        public Dimension getPreferredSize() {
            return new Dimension(135,80);
        public void paint(Graphics g) {
            if (big == null) {
                return;
            big.setBackground(getBackground());
            big.clearRect(0,0,w,h);
            float freeMemory = (float) r.freeMemory();
            float totalMemory = (float) r.totalMemory();
            // .. Draw allocated and used strings ..
            big.setColor(Color.green);
            big.drawString(String.valueOf((int) totalMemory/1024) + "K allocated",  4.0f, (float) ascent+0.5f);
            usedStr = String.valueOf(((int) (totalMemory - freeMemory))/1024)
                + "K used";
            big.drawString(usedStr, 4, h-descent);
            // Calculate remaining size
            float ssH = ascent + descent;
            float remainingHeight = (float) (h - (ssH*2) - 0.5f);
            float blockHeight = remainingHeight/10;
            float blockWidth = 20.0f;
            float remainingWidth = (float) (w - blockWidth - 10);
            // .. Memory Free ..
            big.setColor(mfColor);
            int MemUsage = (int) ((freeMemory / totalMemory) * 10);
            int i = 0;
            for ( ; i < MemUsage ; i++) {
                mfRect.setRect(5,(float) ssH+i*blockHeight,
                                blockWidth,(float) blockHeight-1);
                big.fill(mfRect);
            // .. Memory Used ..
            big.setColor(Color.green);
            for ( ; i < 10; i++)  {
                muRect.setRect(5,(float) ssH+i*blockHeight,
                                blockWidth,(float) blockHeight-1);
                big.fill(muRect);
            // .. Draw History Graph ..
            big.setColor(graphColor);
            int graphX = 30;
            int graphY = (int) ssH;
            int graphW = w - graphX - 5;
            int graphH = (int) remainingHeight;
            graphOutlineRect.setRect(graphX, graphY, graphW, graphH);
            big.draw(graphOutlineRect);
            int graphRow = graphH/10;
            // .. Draw row ..
            for (int j = graphY; j <= graphH+graphY; j += graphRow) {
                graphLine.setLine(graphX,j,graphX+graphW,j);
                big.draw(graphLine);
            // .. Draw animated column movement ..
            int graphColumn = graphW/15;
            if (columnInc == 0) {
                columnInc = graphColumn;
            for (int j = graphX+columnInc; j < graphW+graphX; j+=graphColumn) {
                graphLine.setLine(j,graphY,j,graphY+graphH);
                big.draw(graphLine);
            --columnInc;
            if (pts == null) {
                pts = new int[graphW];
                ptNum = 0;
            } else if (pts.length != graphW) {
                int tmp[] = null;
                if (ptNum < graphW) {    
                    tmp = new int[ptNum];
                    System.arraycopy(pts, 0, tmp, 0, tmp.length);
                } else {       
                    tmp = new int[graphW];
                    System.arraycopy(pts, pts.length-tmp.length, tmp, 0, tmp.length);
                    ptNum = tmp.length - 2;
                pts = new int[graphW];
                System.arraycopy(tmp, 0, pts, 0, tmp.length);
            } else {
                big.setColor(Color.yellow);
                pts[ptNum] = (int)(graphY+graphH*(freeMemory/totalMemory));
                for (int j=graphX+graphW-ptNum, k=0;k < ptNum; k++, j++) {
                    if (k != 0) {
                        if (pts[k] != pts[k-1]) {
                            big.drawLine(j-1, pts[k-1], j, pts[k]);
                        } else {
                            big.fillRect(j, pts[k], 1, 1);
                if (ptNum+2 == pts.length) {
                    // throw out oldest point
                    for (int j = 1;j < ptNum; j++) {
                        pts[j-1] = pts[j];
                    --ptNum;
                } else {
                    ptNum++;
            g.drawImage(bimg, 0, 0, this);
        public void start() {
            thread = new Thread(this);
            thread.setPriority(Thread.MIN_PRIORITY);
            thread.setName("MemoryMonitor");
            thread.start();
        public synchronized void stop() {
            thread = null;
            notify();
        public void run() {
            Thread me = Thread.currentThread();
            while (thread == me && !isShowing() || getSize().width == 0) {
                try {
                    thread.sleep(500);
                } catch (InterruptedException e) { return; }
            while (thread == me && isShowing()) {
                Dimension d = getSize();
                if (d.width != w || d.height != h) {
                    w = d.width;
                    h = d.height;
                    bimg = (BufferedImage) createImage(w, h);
                    big = bimg.createGraphics();
                    big.setFont(font);
                    FontMetrics fm = big.getFontMetrics(font);
                    ascent = (int) fm.getAscent();
                    descent = (int) fm.getDescent();
                repaint();
                try {
                    thread.sleep(sleepAmount);
                } catch (InterruptedException e) { break; }
                if (MemoryMonitor.dateStampCB.isSelected()) {
                     System.out.println(new Date().toString() + " " + usedStr);
            thread = null;
public static void main(String s[]) {
        final MemoryMonitor demo = new MemoryMonitor();
        WindowListener l = new WindowAdapter() {
            public void windowClosing(WindowEvent e) {System.exit(0);}
            public void windowDeiconified(WindowEvent e) { demo.surf.start(); }
            public void windowIconified(WindowEvent e) { demo.surf.stop(); }
        JFrame f = new JFrame("Java2D Demo - MemoryMonitor");
        f.addWindowListener(l);
        f.getContentPane().add("Center", demo);
        f.pack();
        f.setSize(new Dimension(200,200));
        f.setVisible(true);
        demo.surf.start();

Similar Messages

  • How to determine the proper size for Oracle 8i Data Base Objects

    Hi,
    I'm working on an Oracle 8i Data base. I'd like to know how to determine the proper size for the Data Base objects such as tables, datafiles, tablespaces...
    Thanks.

    Start with the docs.
    http://download-west.oracle.com/docs/cd/A87860_01/doc/server.817/a76956/schema.htm#949
    Best Regards
    Krystian Zieja / mob

  • How to determine the field size

    I am going to make a multiplatform application that hopefully
    will run on linux and windows 2000.If the os is 2000, then I will use
    vb.net/aspx else I'll use java servlets. I make the connection
    to the web server ( through HTTP) not directly to database server.
    So, the resultset will be stored in the String object. The columns
    will be separated by delimeter. Our problem is how to determine
    the size and type of the fields of mssql,oracle and postgres database
    so that we can include it in the String object.
    Ex.
    String sResultSet=new String();
    ResultSet rs=statement.executeQuery(sSQL);
    while(rs.next()){
    sResultset=sResultSet + rs.getString(field1) + "||" + rs.getString(field2) + "||";
    vertical bars acts as delimeter
    supposedly this is the code:
    sResultset=sResultSet + rs.getString(field1) +"_" + rs.getFieldType() + "_"+
    rs.getFieldSize() + "||" + rs.getString(field2) +"_" + rs.getFieldType() + "_"+
    rs.getFieldSize() + "||";
    supposedly this is the code if rs.getFieldType() and rs.getFieldSize() methods are existing
    Anyone can give me an idea how to get the field type and field size of the database?
    thanks in advance

    Yes, but I dont know how to do it.
    Can you give me an example of using it.
    Thanks in advance

  • How to determine the database size corresponding to the nber records in DSO

    Hi Colleagues,
    I would like to determine the database size corresponding to my new BI project.
    I know the number of records uploaded in the DSO from the source system for the intialization phase.
    How can I deduct the database size / disk size corresponding to the number of record uploaded ?
    Thanks,

    Hi Ram,
    I am with SAP BI Release SAPKW70019
    I do not have the option Single Table analysis -
    I have in DB02 or ST04 the following options.
    *- Space*
    -- space overview
    ->database
    --overview
    ->users
    --overview
    --detailed analysis
    -> tablespaces
    --overview
    --detailed analysis
    -> segments
    --overview
    --Detailed analysis
    --Detailed Analysis Aggregated
    -> Additional Functions
    --Collector Logs
    --BW Analysis
    Where should I go through ?
    Thanks

  • Tablespace allocation type system  how oracle determines the extent size

    HI
    It may be silly question but the I have to ask and get some knowdge
    Suppose tablespace allocation_type is system then how oracle determins the inital extent and max extent size?

    Was this tablespace converted to locally managed from an existing tablespace? If so, the existing extents still exist after the conversion. Also depending on the Oracle version and maybe platform the pct_increase parameter is still honored after the conversion which can lead to odd sizes. The current value of this parameter may not be the value that was in effect when extents were allocated.
    Also Oracle enhanced the logic to not leave odd sized extents unused so that if by rights the system should take a 64K extent but there is a 56K extent available (perhaps at the end of a file) it can be used to fill the extent request.
    HTH -- Mark D Powell --

  • How to Increase the memory size of a File in the Application Server

    Hello Abaper's
    I have generated a XML file for the data of  internal table (with 10 Records). When i download , i can see the XML file for the Entire 10 Records.
    But , while transferring the XML file to Applicationserver , it's  transferring only upto max 4 Records.I     assume that the memory is insufficient to  allocate 10  Records. Can we Increase the Memory size of the File on Application server. OR,  is there any error in My Source Code.
    Code i used to Transfer the XML File to Application server.
    OPEN DATASET FNAME FOR OUTPUT IN BINARY MODE.
    IF sy-subrc EQ 0.
       LOOP AT it_xmltab INTO wa_xmltab.
           TRANSFER wa_xmltab TO FNAME.
       ENDLOOP.
    ELSE.
      MESSAGE e004(zmsg5) WITH 'File FNAME not opened'.
    ENDIF.
    CLOSE DATASET FNAME.
    Regards
    Jv

    Hi,
    DATA : filename TYPE rlgrap-filename.
    DATA : doc_name TYPE char30.
    DATA : bin_size TYPE i.
    SELECT matnr matkl meins
           FROM mara INTO TABLE it_mara
           UP TO 10 ROWS.
    CALL FUNCTION 'SAP_CONVERT_TO_XML_FORMAT'
      EXPORTING
        i_filename           = filename
        i_xml_doc_name       = doc_name
      IMPORTING
        pe_bin_filesize      = bin_size
      TABLES
        i_tab_sap_data       = it_mara         "  contains  10 Records
      CHANGING
        i_tab_converted_data = it_xmltab.
    placing XML File in Appl. Server
    DATA : FNAME(60) VALUE 'xyz_File'.
    DATA : num TYPE i.
    DATA : xmldata(256) TYPE x.
      For Writing The data in Application Server
    OPEN DATASET FNAME FOR OUTPUT IN BINARY MODE. " ENCODING DEFAULT.
    IF sy-subrc EQ 0.
      LOOP AT it_xmltab INTO wa_xmltab.
        TRANSFER wa_xmltab TO FNAME.
      ENDLOOP.
    ELSE.
      MESSAGE e004(zmsg5) WITH 'File FNAME not opened'.
    ENDIF.
    CLOSE DATASET FNAME.
      For Reading The data in Application Server
    OPEN DATASET FNAME FOR INPUT IN BINARY MODE. " ENCODING DEFAULT.
    DO.
      IF sy-subrc EQ 0.
        READ DATASET fname INTO xmldata.
        WRITE :/ xmldata.
        Clear xmldata.
      ELSE.
        EXIT.
      ENDIF.
    ENDDO.
    CLOSE DATASET FNAME.
    at runtime i can see   
    it_mara  --> contain 10 records
    it_xmltab --> contain 7 lines (Each line size is 255 char). This table have XML format data,  (unknow format , with all numeric 
                        digits)
    it_xmltab is trasferred to application server , but the xml format is generated upto 4 records, and for the remaining records
    the XML format is not generated.
    the XML data in application server file is
    <?xml version="1.0"?><TY_MARA><TY_MARA><MATNR Datatype="C" Length="36">0-BUY1</MATNR><MATKL Datatype="C" Length="18">012</MATKL><MEINS Datatype="C" Length="6">PC
    </MEINS>
    </TY_MARA><TY_MARA><MATNR Datatype="C" Length="36">0-BUY2</MATNR><MATKL Datatype="C" Length="18">012</MATKL><MEINS Datatype="C" Length="6">
    PC </MEINS>
    </TY_MARA><TY_MARA><MATNR Datatype="C" Length="36">000000000000000001</MATNR><MEINS Datatype="C" Length="6">EA</MEINS>
    </TY_MARA><TY_MARA><MATNR Datatype="C" Length="36">000000000000000002</MATNR
    Regards
    JV

  • How to determine the maximum size of JFrame?

    I am using JDK1.2 to develop an application. I have
    a problem to handle the maximum size of of JFrame.
    If the user clicks the maximum icon or double-clicks
    the title bar from the JFrame, the JFrame becomes
    maximum. How can I determine the state of maximization? I need to bring different views if the
    JFrame is maximum or minimum. I knew JDK1.4 can
    handle this problem. Or using JNI, either. Does
    anyone know other ways to handle this?
    Thanks,
    Peter

    So that you won't have to wait forever:
    Sorry, pal, the only way is JNI. I researched this earlier for 1.2, but can't find it right now in the database. They finally added it to 1.4.
    Good luck.

  • How to change the memory size of Iphoto to put more pictures??  I don't have no more space!!!

    Hi....
    I wonted to put some more pictures to Iphoto...but I can't do it because it is telling me that I don't have enough space.... I so that memory on the hard disk for Iphoto is only 37gb ... how can I change that?????  I wont to have all my photos in this program!!
    Thank you for your answers...

    I have trued to clean my hard disk --- but this is not the problem!!
    "IPhoto nn può imporate le foto perchè nn c'è abbastanza spazio libero sul VOLUME che contiene la libreria di Iphoto"
    this is the messege how is coming out....
    it means...
    Iphoto can not import the fotos, because there is not enough free space of VOLUME that containse the library of Iphoto
    do you now that could it be???

  • How to adjust the memory size of partition?

    I have the mac os partition and bootcamp partition in my air now. And I installed win7 into the bootcamp for 190G. So I want to adjust the size of bootcamp and enlarge the mac os partition, and create a new partition for using time machine. Can I make it without losing any data?

    Keeping no backups is a disaster waiting to happen so it is good that you are planning to use TimeMachine, but putting your backup on a partition of the drive you are backing up is almost like having no backup plan. There are lots of reasons you'd need to restore from a backup and many (if not most) would also leave your TM backup unusable. If your hard drive dies you'd have no TM backup. If your partition table is damaged you'd have no backup. If your computer were stolen you'd have no backup. If fire or flood destroyed your computer you'd have no backup. Buy an external hard drive and use that for TM backups and you can leave your computer's hard drive alone.

  • How to determine the size of the JVM process?

    Hi,
    How to determine the total process size of the JVM process (that includes Heap, Non Heap and Native memory)?
    Is there any command to obtain this value on Solaris (for Sun JVM)?
    I refer the process size to http://middlewaremagic.com/weblogic/wp-content/uploads/2010/11/Java_Heap_Diagram_12.jpg) here.
    Many thanks for your help in advance!

    Hi,
    Make sure that Total Heap + Native memory will be consider as total Memory.
    That means in 32 bit you will have only at most 4 GB for process + additional 2 GB for OS.
    So let assume if you have 4GM RAM then out of the 4GB you can allocate 2GB as Heap and 512m as Perm in case of Hot spot and remaining will be consider as Native memory.
    But in case of 64 bit will change you will have good amount of the memory so you can use plenty of Heap and Perm size.
    Still if you have query let me know.
    Regards,
    Kal

  • How do you determine the optimal size for Mozilla Firefox?

    How do you determine the optimal size for cache in Mozilla
    Firefox? I am using Firefox 7.0.1 on a 64-bit Windows 7 Ultimate operating system with 3GB RAM and 300 GB hard drive, but I have other computers running Windows XP. If the answer doesn't apply to all current versions of Firefox on all supported Windows operating systems, please explain the differences. Is there a formula for calculating the best cache size?

    I found that the best idea is to let Firefox decide that itself.

  • How to determine the scratch disc size?

    hello,
    once i was reading an adobe pdf "How to get better performance in photoshop cs5" - that was in 2009 or 2010, and may be outdated, but there was a calculation method
    to determine the size of a scratch disc. (similar calculation see below, if i can remember right)
    i am asking myself, how can i determine the correct size of an external SSD-scratch disc, only used by photoshop (completely empty):
    should i buy a 128GB or 256GB or 512GB SSD which is only reserved for photoshop?
    basic question 1 : i guess i should avoid to set the internal SSD as photoshop scratch disc, as it slows down everything?
    basic question 2 : in sense of maximum performance: better buy an external USB3.0 or thunderbolt SSD? will photoshop really use the extra thunderbolt speed when swapping data?
    secondary question:
    can i calculate the size regarding my daily working habits?
    i am mainly working like this:
    - with my imac 27" late 2013 with 32GB RAM and 256 GB internal pci-e SSD (800 MB/sec), which will stay always half empty for performance reasons.
    - OSX 10.8 mountain lion and 10.9 mavericks soon
    - photoshop cs5, cs6 and cc (always without extended)
    - 8bit and 16bit mode
    - only RGB
    - with latest phocus/Hasselblad and canon RAW Files which produce a basic .psb document at ...
    - 10.000 x 7000 px at 300dpi
    - with average 10 - 40 main image layers and 20-50 adjustement layers (try to reduce that in 16bit)
    - .psb file is 2-20 GB big (file in finder)
    - 16bit file compression is off, when saving .psb files (faster handling)
    -  set photoshop to 70% ram usage (from 32GB RAM)
    i wonder how to calculate ?
    for example:
    10.000 x 7000 px at 300dpi needs for one image layer at 16bit: 2GB RAM in photoshop cs6 or cc (just as a number), this may be wrong
    so lets take 2GB RAM and multiply with 10 image layers in my .psb file (16bit) = 20 GB RAM, and multiply with 20 adjustment layers (guess they need less ram, for one lets say 500MB) = 20GB + 10GB = this 16bit .psb layer file would need 30GB RAM, so when i have 32GB in my imac, i set cs6 or cc to 70% ram usage, it misses at least round 8-10GB RAM > can i guess that photoshop would swap these 8GB onto my scratch disc? or do i miss something important in my thinking?
    tricky thinking
    thanks for help

    station_two wrote:
    The rule of thumb I follow says to figure on 50 to 100 times the size of your largest file ever multiplied by the number of files you have open.  I have seen the scratch file exceed 300 GB once, an admittedly rare occurrence, but it often exceeds 200 GB when stitching large panoramas and the like.
    As an example—and stressing that I'm aware that others have even more scratch space than I do—I keep two dedicated, physically separate hard drives as my primary and secondary Photoshop scratch disks and a lot of GB free on my boot drive for the OS.  I also have 16 GB of RAM installed.
    Additionally, if you only have a single HD, i.e. your boot drive, you'd need it to be large enough to accommodate both the swap files of the OS as well as Photoshop's scratch.
    - i dont use HDD anymore only SSDs, both internal and external
    - i set history state to only 5 or 6, to improve performance
    - i set cache size to 4 and tiles to "big and flat" with 1028kb (there is no "big and much layers" option)
    - is this still the rule of thumb? i read it in 2009 , too, guess it was outdated, as cs6 and cc have improved codes in terms of performance?
    - if you say "50 to 100 times the size of your largest file ever multiplied by the number of files you have open.":
    i will not open more than one document at same time to prevent performance lags, so lets calc like: dokument size in finder (you mean in finder or doc. size shown in photoshop?) = e.g. 5GB x 100 = 500GB, so my external scratch disc SSD, i would buy now, should be at least 500GB, USB 3.0 or thunderbolt ... maybe better thunderbolt, yes? with usb 3.0 i could gain 300MB/sec if thats enough for photoshop?
    thanks

  • In InDesign, how does one determine the pixel size of a text box? Specifically, we need to write text to specifications of 600 pixel width, and have no idea a) how to scale a text box to specific pixel width, b) how to

    This may be a basic question... but in InDesign, how does one determine the pixel size of a text box? Specifically, we need to write text to specifications of 600 pixel width, and have no idea a) how to scale a text box to specific pixel width, b) how to determine what word count we can fit in, and c) how to do it in a table? Thanks!

    Set your ruler increments to pixels Preferences>Units & Increments. You can fill the text box with placeholder text Type>Fill with Placeholder text and get a word count from the Info panel with Show Options turned on from the flyout.
    From the Transform panel you can set a text box's width and height

  • HT1222 how do i determine the file size of each download before i download it?

    How do i determine the file size of a down load before i download it?

    I have checked the update page and even checked more and can find no reference to file size.  I'm using a hotspot and some of the downloads cause me to go over my limit and incur extra charges.  I apperciate your help.

  • I have an ipod I want to sell, but I don't know how to determine the specs, which one it is, how much memory, etc. Where can I find this information?

    I have an ipod I want to sell, but I don't know how to determine the specs, which one it is, how much memory, etc. Where can I find this information?

    See this Apple support document.
    http://support.apple.com/kb/ht1353
    B-rock

Maybe you are looking for