JDK6 locks use a LOT more memory then JDK5

I'm happy user of java 5 concurrency utilities - especially read/write locks. We have a system with hundreds of thousands of objects (each protected by read/write lock) and hundreds of threads. I have tried to upgrade system to jdk6 today and to my surprise, most of the memory reported by jmap -histo was used by thread locals and locks internal objects...
As it turns out, in java 5 every lock had just a counter of readers and writers. In java 6, it seems that every lock has a separate thread local for itself - which means that there are 2 objects allocated for each lock for each thread which ever tries to touch it... In our case, memory usage has gone up by 600MB just because of that.
I have attached small test program below. Running it under jdk5 gives following results:
Memory at startup 114
After init 4214
One thread 4214
Ten threads 4216With jdk6 it is
Memory at startup 124
After init 5398
One thread 8638
Ten threads 39450This problem alone makes jdk6 completly unusable for us. What I'm considering is taking ReentranceReadWriteLock implementation from JDK5 and using it with rest of JDK6. There are two basic choices - either renaming it and changing our code to allocate the other class (cleanest from deployment point of view) or putting different version in bootclasspath. Will renaming the class (and moving it to different package) work correctly with jstack/deadlock detection tools, or they are expecting only JDK implementation of Lock ? Is there any code in new jdk depending on particular implementation of RRWL ?
Why this change was made btw ? Only reason I can see is to not allow threads to release read lock taken by another threads. This is a nice feature, but is it worth wasting gigabyte of heap ? How this would scale to really big number of threads ?
Test program
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.*;
public class LockTest {
  static AtomicInteger counter = new AtomicInteger(0);
  static Object foreverLock = new Object();
  public static void main(String[] args) throws Exception {
    dumpMemory("Memory at startup ");
    final ReadWriteLock[] locks = new ReadWriteLock[50000];
    for ( int i =0; i < locks.length; i++ ) {
      locks[i] = new ReentrantReadWriteLock();
    dumpMemory("After init ");
    Runnable run = new Runnable() {
      public void run() {
        for ( int i =0; i< locks.length; i++ ) {
          locks.readLock().lock();
locks[i].readLock().unlock();
counter.incrementAndGet();
synchronized(foreverLock) {
try {
foreverLock.wait();
} catch (InterruptedException e) {
e.printStackTrace();
new Thread(run).start();
while ( counter.get() != 1 ) {
Thread.sleep(1000);
dumpMemory("One thread ");
for ( int i =0; i < 9; i++ ) {
new Thread(run).start();
while ( counter.get() != 10 ) {
Thread.sleep(1000);
dumpMemory("Ten threads ");
System.exit(0);
private static void dumpMemory(String txt ) {
System.gc();
System.gc();
System.gc();
System.out.println(txt + (Runtime.getRuntime().totalMemory()-Runtime.getRuntime().freeMemory())/1024);

Controlling access/update to data is what DBMS are
all about.And our framework is more or less DBMS.
Imagine that you need a SQL database with following extensions:
If any row you have ever requested is modified, you should get a new version transparently plus get notified about the change (what fields have changed)
If any query you have ever done would return different rows then previously, the result collection should be modified and you should be notified about the change (delta to previous contents).
It is distributed-cache-meets-DBMS framework.
Some of the entities are backed by actual database for persistence, but others are not (they are in transient memory only, or views to data managed by completly different systems).
We could stay with R/W locks for the lists and plain locks for objects - but even the number of lists in the system (5-10k) could already have some effect when multiplied by the number of threads - and originally the cost for having R/W lock per object was relatively small and it seems cleaner and more scalable.
Just from top of my head I can give the example where I was searching the list of the objects for the index to insert a new one in write lock, but I have switched to searching this list in read lock, then changing to a write lock and searching area around previously found place (as list could be modified in the moment lock is upgraded, but in most cases I have to search only 1-2 indices around). This change had incredible perceived performance impact (as rendering code for a JTable was using model based on the same list with a readlock). For single object locking it is not so obvious, but still there are objects which can locked for reading from many threads concurrently.

Similar Messages

  • 3GB Uses a Lot More Memory?

    I had an 8GB Original iPhone. Had hoped to get 16GB 3G, none left, so got 8GB. On my own phone I had 1.7 GB free. Synced new one with a few apps (have checked - dont use much memory). Im disappointed to see in 3G only 292MB left.
    Does the 3G OS etc take up a lot more of the memory?
    Am really happy with the phone apart from this ....

    The iphone is subject to the same gigabyte/gibibyte conversion that hard drives are: you lose about 7% of the stated capacity.
    just as your 500gb drive only has around 465gb available, a 16gb iphone will only have 14.88 available.
    another ~230mb is taken for the version of os x that runs on iphones/ipod touches, and you are left with about 14.5 available.
    these are all approximate since a 16gb iphone may actually have 15.9 or 16.1gb depending on which manufacturer apple chose for the chips and i'm using a round 7% for the conversion.
    i remember an old lacie portable hd of mine that was marketed as 18gb, but was a 16.9gb disk. after the conversion, it was only 15.5 or so. now that was a rip off...

  • Why is firefox 7b using a lot more memory and cpu on my computer?

    I'm trying firefox 7 beta in a debian squeeze box. It is using a lot of RAM and CPU compared to previous releases of firefox(I've tried disabling all plugins and add-ons, not a big improvement). In the follow link here is a summary from about:memory, websites tabs opened at that time and the usage of % mem and cpu of my system: http://pastebin.com/8ji1gmLk
    I'm using firefox on all my computers for a while now. So changing the browser is not an option for me now.
    It did crash few times when loading a lot of tabs. Please let me know if there is another information that would be useful for fixing this. Thanks

    Is it using a significant amount more resources than 6.0 did?
    I noticed 6.0 is a VAST resource hog over 5.0 and earlier. It's a very bad flaw in the new version, and has a lot of people upset.
    What has me curious is whether this is a new resource problem or whether it was present in 6.0 and you are just not noticing it.
    One suggestion: Don't run BETA versions of ANY software on "all your machines". Not when rolling back the version is not an option. That's generally a bad idea, since beta versions are likely to have bugs.
    With FF, now, I would never let it automatically update. I don't trust their new update policies, so I would suggest you turn "auto updates" to OFF, and do it manually, only after you hear the new release is stable, which we know 6.0 is NOT.

  • Server is using a lot more memory since upgrading from LMS 2.6 to 3.2 - any tips?

    /* Style Definitions */
    table.MsoNormalTable
    {mso-style-name:"Table Normal";
    mso-tstyle-rowband-size:0;
    mso-tstyle-colband-size:0;
    mso-style-noshow:yes;
    mso-style-priority:99;
    mso-style-qformat:yes;
    mso-style-parent:"";
    mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
    mso-para-margin:0cm;
    mso-para-margin-bottom:.0001pt;
    mso-pagination:widow-orphan;
    font-size:11.0pt;
    font-family:"Calibri","sans-serif";
    mso-ascii-font-family:Calibri;
    mso-ascii-theme-font:minor-latin;
    mso-fareast-font-family:"Times New Roman";
    mso-fareast-theme-font:minor-fareast;
    mso-hansi-font-family:Calibri;
    mso-hansi-theme-font:minor-latin;
    mso-bidi-font-family:"Times New Roman";
    mso-bidi-theme-font:minor-bidi;}
    Hi, Can anyone tell me if they have a similar situation to mine           
    /* Style Definitions */
    table.MsoNormalTable
    {mso-style-name:"Table Normal";
    mso-tstyle-rowband-size:0;
    mso-tstyle-colband-size:0;
    mso-style-noshow:yes;
    mso-style-priority:99;
    mso-style-qformat:yes;
    mso-style-parent:"";
    mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
    mso-para-margin:0cm;
    mso-para-margin-bottom:.0001pt;
    mso-pagination:widow-orphan;
    font-size:11.0pt;
    font-family:"Calibri","sans-serif";
    mso-ascii-font-family:Calibri;
    mso-ascii-theme-font:minor-latin;
    mso-fareast-font-family:"Times New Roman";
    mso-fareast-theme-font:minor-fareast;
    mso-hansi-font-family:Calibri;
    mso-hansi-theme-font:minor-latin;
    mso-bidi-font-family:"Times New Roman";
    mso-bidi-theme-font:minor-bidi;}
    CiscoWorks LMS was upgraded from version 2.6 to 3.2
    The Server previously ran at 3.5GB of Memory, but following the upgrade now runs at over 5GB of Memory.
    The Server is a HP Proliant DL380 G4.
    The Server has very poor response times following the upgrade, and we need to understand why this has occurred.
    I guess I  need to know if there are some services that you generally disable to improve performance or do we need to upgrade the hardware.
    Device has 4G of physical memory with 4G swap size.
    Any advice appreciated
    Cheers, Dom

    LMS 3.2 does take more memory that 2.6.  There are more daemon processes which run (e.g. there are now two instances of the DFM servers to support scalability to 5,000 devices).  As for how much RAM will be required, that will depend on the number of devices being managed and the other processes running on the server.  With 4 GB of RAM, you should be able to manage up to 1.5K devices provided HUM is not installed, and the server is dedicated to LMS alone.

  • Does Tiger use a lot more memory than Panther

    Hopefully this is my last question before I upgrade. I dont know if I want to do it if Tiger is not as efficient.

    My sister has an older iMac with basically the same processor you have. You actually have two processors. Her iMac has 768mb of ram. She is running 10.4.5 and everything operates just fine.
    One thing I noticed is with Dashboard, even though the Widgets are not actively displayed on the desktop they still will access the processors, and can slow your machine down. You can check this with Activity Monitor. If you are going to do processor intensive tasks, close all widgets, or there is now a widget which will allow you to quit the Dashboard, this will disable all widgets. Also some widgets will access the internet intermittently (news feeds, weather maps and many others) if you have dial-up internet and again if the widgets are not closed, these will impact the speed of your browser and downloads.
    For myself, Tiger has been extremely stable and have not had a single crash of the operating system. I upgraded last May so almost one year.
    hope this helps

  • Flash player 11.3.300.262 is using a lot of memory

    Since updating flash a few days ago the plugin has been using a lot more memory than usual. Normally it uses between 150MB to 200MB, but now i have seen it use up to 900MB.
    I've noticed that memory use increases by 5MB or more when navigating through a video until i have to terminate the plugin because of the ridiculous amount of memory used.

    Please check if all your plugins are up-to-date. To do this, go to the [http://mozilla.com/plugincheck Mozilla Plugin Check site].
    Once you're there, the site will check if all your plugins have the latest versions.
    If you see plugins in the list that have a yellow ''Update'' button or a red ''Update now'' button, please update these immediately.
    To do so, please click each red or yellow button. Then you should see a site that allows you to download the latest version. Double-click the downloaded file to start the installation and follow the steps mentioned in the installation procedure.

  • I have two iphones using the same computer and I can only find a backup for my iphone and not my girlfriends.  She uses itunes a lot more often then I do but cant find it

    I have two iphones using the same computer and I can only find a backup for my iphone and not my girlfriends.  She uses itunes a lot more often then I do but cant find it.  Really need some help.  Shouldnt her apps and details be saved online in the itunes store?  Even her apps wont appear

    If you create an Apple ID for your daughter, signing out of the existing Apple ID with the iTunes & App Store on her iPhone will not change anything on your iPhone.
    All apps include DRM protection which is tied to the Apple ID that was used to download the apps.
    If she starts using her Apple ID to download apps, when there is an app update for an app on her iPhone that was downloaded with the current shared Apple ID, she will need to use that Apple ID and password to download the app updates.

  • Safari 2.0.4 - Uses a lot of memory  ??

    Hello,
    I own an Intel iMac MA200.
    I noticed after Safari's 2.0.4 update that it uses a lot of memory, sometimes even as much as 200MB
    The cure I found is to restart Safari.
    Sometimes, I need to even Force Quit it.
    When I finish using my iMac, and close the Safari windows but let it keep running (red button), go to sleep, and in the morning check how much memory it takes, it's more then 100MB,
    I suspect there is a memory leak with Safari 2.0.4
    My OS X version is 10.4.8.
    I wonder if there is a known problem with Safari, and if there will be a new update released soon (2.0.5 ?) that will solve this problem, because I didn't have this problem with 2.0.3 .
    Thanks in advance,
    Idan Mashaal.
    iMac MA200 (Intel 20")   Mac OS X (10.4.8)   1GB single Dimm RAM

    Hey !
    Thanks for the post!
    Sience the Gmail upgrade, Safari stopped being my default browser.
    I'm using JCraig's optimized nightly builds for Camino (1.2+)
    They seem very memory friendly and Intel Optimized.
    http://homepage.mac.com/WebObjects/FileSharing.woa/wa/default?user=joelcraig23&t emplatefn=FileSharing2.html&xmlfn=TKDocument.2.xml&sitefn=RootSite.xml&aff=consu mer&cty=US〈=en
    I really hope Apple will fix the memory leak and Gmail fix there new interface (the little option button next to the new reply deosn't work - even with WebKit nightly) ASAP - sience SafariBlock and Saft doesn't work well with WebKit Nightly.
    I miss my Safari
    Idan.
    iMac MA200 (Intel 20")   Mac OS X (10.4.8)   1GB single Dimm RAM

  • When I regist function to lua,use a lot of memory

    when I regist c++ class and function to lua,the class or funtion may use templete.It use a lot of memory.
    Just registed about 1000 functions,The memory of running swf is about 1.8G.
    Then the swf exit without any exceptions.The same code run at win7,just need 100M.
    Can any give any suggestion?
    Thanks.

    I'm not sure what you mean by registering classes and functions. Have you tried running Adobe Scout on the SWF, it might give more info about what is taking up so much memory: http://gaming.adobe.com/technologies/scout/

  • ScanToPCActivationApp.exe is using a lot of memory even though the printer is off.

    ScanToPCActivationApp.exe is using a lot of memory even though the printer is off. 
    Upon computer boot up, Task Manager shows it is using 45mb, and after researching this topic using IE, 10 minutes later it now shows it is using 74 mg, although it did go down to 33 mg a few minutes later, then back up to 51 mg a few minutes after that. 
    Is there a way to keep it from using so much memory when the printer is turned off?. 
    I am running Windows 7 on a Samsung Series 7 laptop and my printer is an HP 8600 All-in-one.  I do use ePrintCenter occasionally, and also have a MacBook Pro (running Mountain Lion), and iPhone 4 (running the latest IOSupdate) and all devices connect to the printer wirelessly. 
    Please let me know if there is more info that you require.  Thank you in advance!

    The best thing to do is uninstall iTunes and install turn to him, but another look from thedownload page do not you reinstall the exe you have already installed ahy maybe youriTunes installer is in bug

  • My saved messages are using a lot of memory.  How do I free up the memory?

    My saved imessages are using a lot of memory (3.1GB) on my iphone.  How can I free up the memory?

    This is when I go to "usage" and it lists all of the memory used by certain apps.  Messages is the largest, and I swipe to the left to open it and it says that "saved messages" are using all of it.  There is no option to do anything at this screen.

  • My ituneshelper.exe is using a lot of memory.

    My ituneshelper.exe is using a lot of memory. I-tunes is not running and my I-pod is not attached.
    Is there anything I can do about this? Can I stop this from loading at start-up and only load when I open I-tunes?
    If so .. how???

    The best thing to do is uninstall iTunes and install turn to him, but another look from thedownload page do not you reinstall the exe you have already installed ahy maybe youriTunes installer is in bug

  • SystemUIServer is using a lot of memory

    My systemUIServer is using a lot of memory like 300MBof memory. I can quit the serives which is relaucnched since it's a launchd and will gradually go back to eating up memory. I also have noticed the LoginWindow process eats up a lot of memory. Does anyone know what could be causing this

    systemUIServe and loginwindows is using 800+1gb of my ram. I m rearching for a fix  did you solve yours?

  • A process named "update.exe *32" and description is "Firefox" keeps using a lot of memory and cpu; the longer forefox is on, the worse it gets. How to prevent?

    using Windows 7, firefox 15.0.1
    This process uses more and more memory and CPU, sometimes there are several of these processes running. If I kill these processes, it doesn't seem to affect the utilization of Firefox. Then the process slowly starts to use more and more memory and CPU all over again.
    This happens all the time, every time I use Firefox.

    I do not have a ComObjects folder under C:\Program Files (x86)\Common Files. That is not part of Firefox.
    wscript.exe is a utility included with Windows to run scripts at the system level. It generally is not used by major programs. If update.exe is starting up with Windows, you may be able to find the script that wscript.exe is running using [http://technet.microsoft.com/en-us/sysinternals/bb963902.aspx Autoruns].
    It definitely sounds viral. I suggest deleting the update.exe file, although Windows might prevent you from doing that until you kill all related processes. And if you have a persistent infection, the file may be restored or re-downloaded.
    It might be easiest to seek assistance from a forum more dedicated to malware cleanups such as the following:
    * [http://www.bleepingcomputer.com/forums/forum22.html Virus, Trojan, Spyware, and Malware Removal Logs - BleepingComputer.com]
    * [http://forums.majorgeeks.com/forumdisplay.php?f=35 Malware Removal - MajorGeeks Support Forums]
    Hope you get it removed.

  • Why the samples of 10_MessageChannel  which run using a lot of memory (330M)

    wether many pthreads communiation with each other , would prompt flacc alloc a lot of memory

    Thread with crossbridge require lots of memory. There is a better explanation here : The memory usage of threads · crossbridge-community/crossbridge Wiki · GitHub

Maybe you are looking for

  • XI Error in Integration Directory adapter list is not display.

    Hi All, We are getting following error message while creating communication channels in Integration directory. More over we have attached error log file with this message. ERROR :- u2022     Connection to system REPOSITORY using application REPOSITOR

  • ASO - member level formula - rolling up non-additive values

    <p>I am trying to roll up not additive values (Yields, Percents,Spreads, etc.). In order to do this I have weighted members andmembers to weight them with. This seems to be working okay until Iget to a level where the weighting values are different.

  • Cleanning Planning Levels

    Hi Experts, We have in ower environment server a lot of  planning levels which were made only for test.  How can we identify easly and quicly, the planning levels-planning function that are involved/included in any sequence and which are not involved

  • Safari not loading whenever I turned on my mac

    Hi I need help coz whenever I open my Mac then Safari it always not loading. I tried checking my internet connection and it was excellent. I tried refreshing and force quit any other apps including safari but still not loading. Then, I tried restarti

  • Authorization limits exceeded

    I have reached the authorization limit for my account in Adobe Digital Editions because I had to authorize/deauthorize/reauthorize devices. Could you please reset the authorization limit for me?