Why does the JRE use so much memory?

I know this question has been asked a million times in one form or another but I have not seen a complete answer yet. When I compile and run the following code under WindowsXP pro, it appears that the JRE is using 3.1MB or RAM. When I run a similar program using C++ the program only uses 630k.
public class HelloWorld
public static void main(String args[])
System.out.println("Hello World");
Why 3MB to show "HelloWorld"? I love Java, it is much easier and more enjoyable to develop with but our applications appear to use large amounts of memory. I realize that making calls to the runtime object to check the amount of "heap" memory we are using will probably show much less memory being used but Task Manager shows 3MB. It is sometimes hard to convince my fellow developers of he benefits of Java when there are strange issues like this.
Thanks in advance

Java uses that much memory because every time you start a Java program, even this small, it loads into RAM the whole Java Virtual Machine. Which is itself a very large C++ program - on the order of several hundred thousand lines. Compare that to your C++ HelloWorld program - and you see the reason for a difference...
So a real question is, is it possible to write a modern Java VM such that it uses space proportional to the size/complexity of the Java program that it executes. Partially that's possible - for example I understand that say native GUI libraries are separate from the main JVM dll, so when you don't use AWT/Swing, you don't waste space with related native code. However, for the core JVM it's probably very difficult to separate parts of functionality such as the interpreter, the dynamic compiler, the runtime system, the garbage collector, the serviceability stuff, etc. They are very interdependent, and thus, probably unless you have this goal from the beginning (and ready to sacrifice some performance/maintainability for it), you can't do that.
There exist, however, a bunch of other JVMs of all sizes, say those used in mobile phones (or even smart cards!), that consume a lot less memory. They, however, typically implement only a subset of the full Java functionality. On the other hand, the HotSpot VM that comes with Sun's JDK, that you probably use, is a full-fledged JVM that implements everything, can be used for huge server apps, etc. - no wonder its minimum memory consumption is a few megs.

Similar Messages

  • Why does the radio use so much power?

    I have an iPod Nano..forget which generation but it's the small square one, c2011.
    Why does using the radio drain the battery so much faster than listening to MP3s does?

    Right..ok, then, so what the chip is doing is some kind of automatic gain control..compressor expander type thing? The consumption is so striking..I can probably get 2, maybe 3 days' worth of mp3 play.
    lucky if I could get 4 hours' from the radio.
    Still can't believe all that little gizmo does in the space of about 1 cubic inch.

  • Why Does Flash Player Use So Much Memory In Lion?

    Forgive me if this has been asked, elsewhere.  I have an issue I have been seeing since upgrading to Lion (10.7.3) and the latest version of Safari (5.1.3, I believe?).  When browsing the web for a while (particularly, Flash heavy sites, I have noticed my computer's temperature getting hot and more beach balling starting to occur.  The first time this happened, I opened Activity Monitor and noticed that Flash Player was using, almost, 900 MB of RAM (and I had less than 100 MB available).  Other than Safari, I only had a couple of other applications open, neither of which were memory intensive.  Quitting Safari gave me back a huge amount of memory, my temperatures, quickly, dropped back down to reasonable levels, and the performance lag went away.  Anyone know why this is happening in Lion?  I never saw this kind of memory hogging under Snow Leopard.  Is Flash Player this much of a nuisance under, either, Firefox or Chrome?  Is there anything I can do to alleviate this?
    I have a 2010 MacBook Pro, 2.53 GHz, i5 with 4 GB of RAM.
    Thanks.

    Clear your History and Cache more often.

  • Why does Safari eat up so much memory?

    Hi,
    I've finally had it with Safari and have switched to Camino.  I'd like to know why Safari eats up so much memory.  Things will be going slow, I'll get the rainbow swirl and I'll open the activity monitor and see that Safari has two different process names going on, on of which is eating 2GB +.  Just to compare, I'll open the same windows in Camino and I'll get a maximum usage of 300 MB. 
    The issue only got worse after the last update. 
    Thank you,
    steven

    Hi, sorry I didn't reply sooner.  For some reason, this post doesn't come up when I look in "my discussions" at the top.
    Currenly I have a 1TB HD with 700 GB used, I have 9 TB external HD (1TB for Time Machine, the rest for storage) that's only half full.  And yes, I use video editing software extensivly and Pages as well.  I'll often surf while writing to research and I have programs like Outlook running in the background.  The one thing which has become a problem is playing Flash (like streaming The Daily Show), which becomes choppy and slows down Safari to a crawl.  I thought it was my Internet connection but I have 10mps, super fast.
    @ Johm, about page outs, here's the data
    Page Ins 7.05
    Page outs 57.3
    Swap Used 51.3
    VM size 183
    I'm guessing I should purchase some memory based on these numbers.  Memory isn't as cheep in Japan as it is in the states, at least not for Mac.  Does anyone have a suggestion for a brand I should look out for or any stats that will help me decide which type to purchase or how much?
    Thank you much,
    Steven

  • Why does the flash video have much higher contrast when the window is maximized?

    When using Mozilla Firefox, any flash videos like those on youtube, when maximized, shows much higher contrast. The video becomes so dark that it is pretty difficult to view it. When zoomed out, everything looks normal.
    The work around I ended up using, was to maximize the window using ctrl++ option without using the "fullscreen" button. It is a hassle, but it works. Does anyone know why this happens?
    I use Mozilla FF 19.0.2. Btw, this doesn't happen on Chrome or IE.

    [HKEY_CURRENT_USER\Control Panel\Colors]
    "Window"="0 0 0"
    *http://superuser.com/questions/579227/getting-rid-of-white-flash-in-windows-8-high-contrast-mode

  • Why does the K5400 use up colour ink when printing greyscale?

    Please let me know why all K5400 printers use up the coloured inks when printing only grey scale, is there a way of stopping this waste of inks.?

    There are a few possibilities:
    The color drops are typically much smaller than the black drops so color is used for grayscale graphics unless "use black only" is checked in the driver.  Depending on your operating system and driver this may be an option.
    Black ink is generally not compatible with photo paper.  If you are using photo paper only color ink will be used.
    Color ink is used for servicing to keep the nozzles clear.  See here for information on how ink is used.
    Bob Headrick,  HP Expert
    I am not an employee of HP, I am a volunteer posting here on my own time.
    If your problem is solved please click the "Accept as Solution" button ------------V
    If my answer was helpful please click the "Thumbs Up" to say "Thank You"--V

  • Why does the iPhone not have expandable memory (i.e. MicroSD Chips)?

    I know that many phones come with a MicroSD slot to come with the phone, but why does Apple NOT provide a slot for the iPhone. I would like to know the answer to this hardware puzzle, because many competing phones have these advantages. The only upside I see in the iPhone is web versatility and stability, and that's diminishing very very fast.

    Why close it? Some people might be interested in reading it.
    No, posting on a site for a different product saying your product doesn't meet my needs make it like a Surface is trolling. Chiding someone who made a comment 2 years ago who isn't even here is trolling.
    Basically what you did was buy a product that you knew didn't have 2 important features that you think are essential and now you want Apple to add that. And even if they did add that then you would be posting about the fact that you can't copy anything to the USB or microSD device and you can't copy apps, documents, etc. Which is because iDevices don't have an accessible file system. And you've already mentioned you want that. Due to security reasons it isn't going to happen.
    What you've said you need is a table that is a full computer. You need to buy the Surface Pro (skip the RT, there are limitations you will not be happy with). It will give you a USB port, accessories for a microSD and a fully accessible file system.
    The good news is Apple's devices hold resale value far, far better than any other comparable devices. So sell yours and get a Surace Pro. You will be glad you did.

  • Why does the font used for iTunes show as an outline?

    I cannot get the font used for iTunes to change from an outline. I am using Suitcase Fusion and have turned on and off the Office fonts etc.

    Try this: Go to Control Panel, Fonts.
    On the left pane click "Font settings" > uncehck "Hide fonts based on language settings" > Click "Ok" at the bottom. Restart you computer just to be sure the setting went through. See if that helps.

  • Why would firefox be using so much memory that the application itself freezes to the point where I have to force the program to end?

    For the past few days, I've been doing research for a presentation that I am doing for college. As I've been using Firefox, the program freezes to the point where I have to force the program to terminate. I have a computer with 8 gigs of ram and an i5 quad core processor running at 2.8 ghz. There are no viruses or spyware on the system, and there isn't anything else running. There are no addons applied to my browser, and no personas. There should be no memory issues to the point where an internet browser would freeze this badly.

    Start Firefox in <u>[[Safe Mode]]</u> to check if one of the extensions or if hardware acceleration is causing the problem (switch to the DEFAULT theme: Firefox (Tools) > Add-ons > Appearance/Themes).
    *Don't make any changes on the Safe mode start window.
    *https://support.mozilla.com/kb/Safe+Mode
    *https://support.mozilla.com/kb/Troubleshooting+extensions+and+themes

  • Why does the text used in Flash file gets cut off in swf?

    Please help.
    I am using some text in FLA and when I test movie or publish swf. I see the end of the last word in the text line cut off.
    I tried putting extra space after that and that solved the problem yesterday but today again I face the same problem and the problem is not getting solved with the same solution.
    Does anybody know why it's happening?
    Please let me know.
    Thanks in advance.

    one query: if file is created relative to Java and Tomcat starts from bin directory, them
    file should have been created in c:\tomcat6\bin\abc.txt,
    NOT at c:\tomcat6\abc.txt
    Am I write?
    --Sujoy                                                                                                                                                                                                                                                                                                                                                                                                               

  • Why does the library image look much better than develop image?

    I'm noticing a huge difference in IQ even after post processing between the library image and the develop image within Lightroom 2.1 itself. Any reason why? Thanks.

    In what way? The Library image is just a rendering of the Develop image. In Develop, the sharpening and noise reduction are only applied at the 1:1 view to speed it up and to not lie to you (which it would if shown at lower magnification).

  • Why are my photos using so much memory?

    I typically upload my photos from my iPhone 6 to iPhoto after a few months, then delete them all when prompted to do so on iPhoto. I then copy some photos I want to keep on my phone, and go on about my day. However, I noticed how much space photos are taking up on my phone: 2.2 gigs! I only have 99 photos and 1 video on my phone, so how is this possible and what can I do to free up space?

    I deleted all my photos and it still says my photos are taking up space with the Photo Library under the Photos & Camera tab.

  • Why does my mx410 use so much black ink?

    I swear i put in a black ink cartridge and its out after only printing like 6-10 small invoices. This is the third ink cartridge I have had issues with and the last one was a canon cartridge. 

    Hi lmtrzb, The amount of pages an ink cartridge will produce will depend on the print quality and type of paper selected, as well as the type of documents being printed. To conserve the amount of ink being used by the printer, you will want to ensure that the paper type selected in the printer driver is PLAIN PAPER unless you are printing photos, labels or envelopes, and that the print quality is set to either FAST or STANDARD.  If you would like instruction for setting these items in the printer driver, please call or email us using one of the methods on the Contact Us page for assistance.

  • Why does the CS6 Master Collection Suite take up so much RAM on a computer??

    so, if, i brought the CS6 Master Collection Suite i would need more RAM on my computer right?
    because, my apple computer only has 4GB of memory and that program needs 4GB of RAM.
    I would need to add more memory to my apple computer say upgrade it to maybe 8GB of RAM??
    But, i don't understand why does that suite need so much memory or RAM on a computer??
    could i just only download the programs i really need onto my apple laptop and maybe that
    would free up some memory or RAM so that the program wouldn't  end up using all of the memory
    on my computer could i just do that??
    Message was edited by: mzpretty3

    Mzpretty3 you can find the system requirements for CS6 Master Collection at http://helpx.adobe.com/x-productkb/policy-pricing/cs6-system-requirements.html#CS6_Master_ Collection_system_requirements.  For Mac OS we recommend a minimum of 4 GB of RAM and if you are going to do heavy photo or video editing then you will want to have at least 8 GB of RAM available.
    Please also be aware that the installation will require at least 15.5 GB of hard drive space.  This is separate from the amount of RAM which you have installed.

  • Firefox use too much memory

    Hi
    I had this problem one weak ago, I did all suggestion that this link said and it didn't help:
    https://support.mozilla.org/ar/kb/firefox-uses-too-much-memory-ram#w_disabling-memory-consuming-plugins
    I don't have many taps oppened only 47 taps.
    My firefox now usiing 2GB ram, can anyone help me how to fix it?
    Thank you

    Hello,
    Can you please follow the instructions in the ''Memory troubleshooting tools'' section of the [[Firefox uses too much memory (RAM) - How to fix]] support article and provide the about:memory section details in this ticket. We can take a look at it and suggest possible options.
    Thank you

Maybe you are looking for

  • How do you obtain albumart?

    I have a not-so-small music collection (~60gb) and most of the albums miss album art. Does anybody know a better method instead of go to amazon, search album, download image, copy to the right folder, rename...? There is the app 'albumart' in AUR but

  • Cisco ip phones and cme help

    Hi, Ina company which uses cisco call manager express with ip phones 7931, 7945 ,7975, 7911,7962--. 1- i want the configuration in which the user dial a pin code befor doing an outside call...? 2- i want to change the defalt configuration for the ip

  • Order multiple quantity in item master data

    Hello experts, I cannot  import from Excel file new values for order multiple quantity in item master data (in section planning data). After importing I see that  records were imported successfully, but all data which we put in past have been  change

  • How to include STO PR availability check while DRP run?

    Hello gurus, I will explain my scenario by following ex. 1. Suppose i have a requirement in Plant A of quantity 500. 2. Plant B has stock of 800 Q 3. But there is a outbound STO PR of quantity 500 from PLANT B to Plant C. 4. So, now when i run DRP, i

  • Removal of ItemCycleCount from ItemWarehouseInfo

    DI API 2007 Is there a way to remove a ItemCycleCount from a Items-->ItemWarehouseInfo using the DI API? Items>ItemWarehouseInfo>ItemCycleCount Since the ItemCycleCount object does not have a remove method, I have tried updating the Items with a xml