agent/src/share/classes/sun/jvm/hotspot/memory/CompactibleFreeListSpace.java

Print this page
8005278 : Serviceability Agent: jmap -heap and jstack -m fail
   1 /*
   2  * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


 100       long usedSize = 0L;
 101       for (Iterator itr = regions.iterator(); itr.hasNext();) {
 102          MemRegion mr = (MemRegion) itr.next();
 103          usedSize += mr.byteSize();
 104       }
 105       return usedSize;
 106    }
 107 
 108    public long free() {
 109       // small chunks
 110       long size = 0;
 111       Address cur = addr.addOffsetTo( indexedFreeListField.getOffset() );
 112       cur = cur.addOffsetTo(IndexSetStart*FreeList.sizeOf());
 113       for (int i=IndexSetStart; i<IndexSetSize; i += IndexSetStride) {
 114          FreeList freeList = (FreeList) VMObjectFactory.newObject(FreeList.class, cur);
 115          size += i*freeList.count();
 116          cur= cur.addOffsetTo(IndexSetStride*FreeList.sizeOf());
 117       }
 118 
 119       // large block
 120       BinaryTreeDictionary bfbd = (BinaryTreeDictionary) VMObjectFactory.newObject(BinaryTreeDictionary.class,
 121                                                                                    dictionaryField.getValue(addr));
 122       size += bfbd.size();
 123 
 124 
 125       // linear block in TLAB
 126       LinearAllocBlock lab = (LinearAllocBlock) VMObjectFactory.newObject(LinearAllocBlock.class,
 127                                                                           addr.addOffsetTo(smallLinearAllocBlockFieldOffset));
 128       size += lab.word_size();
 129 
 130       return size*heapWordSize;
 131   }
 132 
 133    public void printOn(PrintStream tty) {
 134       tty.print("free-list-space");
 135       tty.print("[ " + bottom() + " , " + end() + " ) ");
 136       long cap = capacity();
 137       long used_size = used();
 138       long free_size = free();
 139       int  used_perc = (int)((double)used_size/cap*100);
 140       tty.print("space capacity = " + cap + " used(" + used_perc + "%)= " + used_size + " ");
 141       tty.print("free= " + free_size );
 142       tty.print("\n");


   1 /*
   2  * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


 100       long usedSize = 0L;
 101       for (Iterator itr = regions.iterator(); itr.hasNext();) {
 102          MemRegion mr = (MemRegion) itr.next();
 103          usedSize += mr.byteSize();
 104       }
 105       return usedSize;
 106    }
 107 
 108    public long free() {
 109       // small chunks
 110       long size = 0;
 111       Address cur = addr.addOffsetTo( indexedFreeListField.getOffset() );
 112       cur = cur.addOffsetTo(IndexSetStart*FreeList.sizeOf());
 113       for (int i=IndexSetStart; i<IndexSetSize; i += IndexSetStride) {
 114          FreeList freeList = (FreeList) VMObjectFactory.newObject(FreeList.class, cur);
 115          size += i*freeList.count();
 116          cur= cur.addOffsetTo(IndexSetStride*FreeList.sizeOf());
 117       }
 118 
 119       // large block
 120       AFLBinaryTreeDictionary aflbd = (AFLBinaryTreeDictionary) VMObjectFactory.newObject(AFLBinaryTreeDictionary.class,
 121                                                                                    dictionaryField.getValue(addr));
 122       size += aflbd.size();
 123 
 124 
 125       // linear block in TLAB
 126       LinearAllocBlock lab = (LinearAllocBlock) VMObjectFactory.newObject(LinearAllocBlock.class,
 127                                                                           addr.addOffsetTo(smallLinearAllocBlockFieldOffset));
 128       size += lab.word_size();
 129 
 130       return size*heapWordSize;
 131   }
 132 
 133    public void printOn(PrintStream tty) {
 134       tty.print("free-list-space");
 135       tty.print("[ " + bottom() + " , " + end() + " ) ");
 136       long cap = capacity();
 137       long used_size = used();
 138       long free_size = free();
 139       int  used_perc = (int)((double)used_size/cap*100);
 140       tty.print("space capacity = " + cap + " used(" + used_perc + "%)= " + used_size + " ");
 141       tty.print("free= " + free_size );
 142       tty.print("\n");