Garbage collection mechanism used in Java??

what garbage collection mechanism used in current java implementation??
mark and sweep algorithm, or reference counting, or other else??

Reference counting is very slow and cannot free unused objects in simple situations, so it would be used only in the very simplest JVMs, if at all. Most modern JVMs use generational garbage collection to quickly collect the majority of objects, which have a very short lifetime.

Similar Messages

  • Garbage collection Java Virtual Machine : Hewlett-Packard Hotspot release 1.3.1.01

    "Hi,
    I try and understand the mechanism of garbage collection of the Java Virtual Machine : Hewlett-Packard Hotspot release 1.3.1.01.
    There is description of this mechanism in the pdf file : "memory management and garbage collection" available at the paragraph "Java performance tuning tutorial" at the page :
    http://h21007.www2.hp.com/dspp/tech/tech_TechDocumentDetailPage_IDX/1,1701,1607,00.html
    Regarding my question :
    Below is an extract of the log file of garbage collections. This extract has 2 consecutive garbage collections.
    (each begins with "<GC:").
    <GC: 1 387875.630047 554 1258496 1 161087488 0 161087488 20119552 0 20119552
    334758064 238778016 335544320
    46294096 46294096 46399488 5.319209 >
    <GC: 5 387926.615209 555 1258496 1 161087488 0 161087488 0 0 20119552
    240036512 242217264 335544320
    46317184 46317184 46399488 5.206192 >
    There are 2 "full garbage collections", one of reason "1" and one of reason "5".
    For the first one "Old generation After " =238778016
    For the second "Old generation After " =238778016
    Thus, "Old generation Before garbage collection" of the second is higher than "Old generation After garbage collection". Why?
    I expected all objects to be allocated in the "Eden" space. And therefore I did not expect to s

    I agree but my current Hp support is not very good on JVM issues.
    Rob Woollen <[email protected]> wrote:
    You'd probably be better off asking this question to HP.
    -- Rob
    Martial wrote:
    The object of this mail is the Hewlett-Packard 1.3.1.01 Hotspot JavaVirtual Machine
    release and its garbage collection mechanism.
    I am interested in the "-Xverbosegc" option for garbage collectionmonitoring.
    I have been through the online document :
    http://www.hp.com/products1/unix/java/infolibrary/prog_guide/java1_3/hotspot.html#-Xverbosegc
    I would like to find out more about the garbage collection mechanismand need
    further information to understand the result of the log file generatedwith the
    "-Xverbosegc"
    For example here is an extract of a garbage collection log file generatedwith
    Hewlett-Packard Hotspot Java Virtual Machine. Release 1.3.1.01.
    These are 2 consecutive rows of the files :
    <GC: 5 385565.750251 543 48 1 161087488 0 161087488 0 0 20119552 264184480255179792
    335544320 46118384 46118384 46137344 5.514721 >
    <GC: 1 385876.530728 544 1258496 1 161087488 0 161087488 20119552 020119552 334969696
    255530640 335544320 46121664 46106304 46137344 6.768760 >
    We have 2 full garbage collections, one of Reason 5 and the next oneof Reason
    1.
    What happened between these 2 garbage collections as we got : "Oldgeneration
    After" of row 2 is higher than "Old generation Before" of row 1? Iexpected Objects
    to be initially allocated in eden and so we could not get "old generation2modified
    between the end of one garbage collection and before the next one.
    Could you please clarify this issue and/or give more information aboutgarbage
    collection mechanisms with the Hewlett-Packard Hotspot Java VirtualMachine. Release
    1.3.1.01.

  • Cache voluntary garbage collection called

    We have installed Oracle Web Cache 2.0.0.4.0 on Windows 2000. We setup the Maximum cache size parameter to 1000Mb, but, when we try to caching a web using WGET, Oracle Web Cache return a "cache voluntary garbage collection called" in the file of log: "event_log".
    What is the problem?

    The message you're seeing in the event log isn't necessarily a problem. The cache has a voluntary garbage collection mechanism that "wakes up" periodically, checks to see if the system is sufficiently idle, and begins to clear out garbage (invalidated/expired) files. This is different from "forced garbage collection", which occurs when the cache nears its maximum size.
    Are you able to cache content? Are you seeing responses served out of the cache?
    I would strongly advise you to upgrade to release 9.0.2, available for download on OTN. There is also a migration tool there for moving from 2.0.0.x to 9.0.2.x. After you've migrated, you can optionally apply the 9.0.2.1 patch set, available on Metalink.

  • Array garbage collection

    I need to keep track of what objects got garbage collected in a program.
    So I made sure that the classes of interest have a 'finalize()' method that simply print out the toString() and reference of the garbage collected object (using System.identityHashCode(this)).
    This worked fine for all objects except arrays.
    I went as far as substituting my own version of java.lang.Object that has an appropriate finalize(), but still no finalize() method seem to be getting called when an array object is 'supposed' to be garbage collected (the process consumes most of the system memory...)
    Any thoughts?
    Thanks,
    Wes

    Just an idea. You can try using WeakReference. Rather than using finalize, you can use the clear method of Reference.
    Here is some pseudo code
    .. class GCWatcher{
    List wrl = ...
    public void watch(Object obj){
    wrl.add(new WatchableWeakReference(obj));
    .. class WatchableWeakReference{
    WathableWeakReference(Object obj){
    super(obj);
    public void clear(){
    wrl.remove(this);
    Object obj = get();
    print out your message
    super.clear();
    If you try it let me know if it worked.

  • Long pauses during ParNew garbage collection Please Help !

    Hi,
    We are running a server application on an large machine (~120 CPU, ~380 GB Memory).
    After running 1 or 2 hours we suddenly get exorbitant application pause times during garbage collection and a massive cpu usage from the java vm
    We are running on Java 6 (64Bit) with 6GB Heap.
    Concurrent garbage collection is turned on using the parameters:
    -XX:+UseConcMarkSweepGC
    -XX:+CMSParallelRemarkEnabled
    -XX:CMSInitiatingOccupancyFraction=80
    -XX:+DisableExplicitGC
    We turned on verbose garbage collection and are getting the following output:
    1. Normal operation:
    Application time: 217.4656792 seconds
    3180.905: [GC 3180.906: [ParNew
    Desired survivor size 20119552 bytes, new threshold 4 (max 4)
    - age   1:    2843824 bytes,    2843824 total
    - age   2:    2577128 bytes,    5420952 total
    - age   3:    5742024 bytes,   11162976 total
    - age   4:     625672 bytes,   11788648 total
    : 329531K->15764K(353920K), 0.1484379 secs] 2435799K->2122105K(3392144K), 0.1492386 secs]
    Total time for which application threads were stopped: 0.1886810 seconds
    2. The Problem:
    Application time: 2.8858445 seconds
    5008.433: [GC 5008.434: [ParNew
    Desired survivor size 20119552 bytes, new threshold 2 (max 4)
    - age   1:   15837712 bytes,   15837712 total
    - age   2:   12284416 bytes,   28122128 total
    : 348338K->39296K(353920K), 138.5317715 secs] 2487779K->2192551K(3392144K), 138.5327383 secs]
    Total time for which application threads were stopped: 138.5778558 seconds
    Application time: 2.9764564 seconds
    5149.957: [GC 5149.957: [ParNew
    Desired survivor size 20119552 bytes, new threshold 2 (max 4)
    - age   1:    9483176 bytes,    9483176 total
    - age   2:   14499344 bytes,   23982520 total
    : 353920K->39296K(353920K), 231.5110574 secs] 2507175K->2204546K(3392144K), 231.5121011 secs]
    Total time for which application threads were stopped: 231.5257754 seconds
    Application time: 2.7932907 seconds
    5384.277: [GC 5384.278: [ParNew
    Desired survivor size 20119552 bytes, new threshold 4 (max 4)
    - age   1:   10756376 bytes,   10756376 total
    - age   2:    9135888 bytes,   19892264 total
    : 353920K->28449K(353920K), 256.2065591 secs] 2519170K->2207651K(3392144K), 256.2076388 secs]
    Total time for which application threads were stopped: 256.2221463 seconds
    I can't find any significant differences in the log between fast and long running garbage collections.
    I urgently need help in solving this problem !
    What can I do ?

    After the exciting reply I did get on my question, we did some more investigations on the problem and it seems that we finally found the solution to our problem.
    The number of garbage collection threads used by the virtual machine defaults to the number of cpus of the machine.
    This is ok for small machines or machines where the main load is produced by the java application itself.
    In our environment the main load is not produced by the java application but oracle database processes.
    When java tries to do it's garbage collection using 120 threads (# CPU) on the machine which is already overloaded by non java processes, the thread synchronization seems to produce an exorbitant overhead.
    My theory is that spin locking is used on memory access, causing threads to spin while waiting for other blocking threads not getting cpu because of the heavy load on the system.
    The solution is now to limit the number of garbage collection threads.
    We did that on the first try by setting -XX:ParallelGCThreads=8
    For over one day with heavy load no long GC pauses were experienced any more.

  • JInternalFrame & Garbage Collection

    I am looking for a work-around for the long standing bug [4759312|http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4759312]. In this bug, the JDesktopFrame maintains a reference to the last JInternalFrame to be closed, preventing it from being garbage collected. The recommendation that I have seen elsewhere is to remove everything from the JInternalFrame's contentPane so that those component's can be collected even if the JInternalFrame is not. However, that approach is not working for me. Here is an example that demonstrates the problem:
    Edited: Removed example as it contained some typos, see below
    If you create a new window, and then close it, the SimplePanel it stays in memory. My debugger shows that it's only references are it's button and layout manager. However, the button is referenced from JInternalFrame.lastFocusOwner, which is probably what is preventing it from being collected.
    How can I clear this reference? Is there another workaround to this bug that works better?
    Sorry, if this has been addressed before - the search on the old forums.sun.com is taking several minutes to respond to a query.
    Edited by: 797984 on Sep 30, 2010 11:49 AM

    6.th JInternalFrame raised (Netbeans debuger has correct delay) you can test it if you runs your code with builded profilier (Profile)
    run BuiltIn Profilier in NetBeans and check which Object exists, are still registred in current JVM instance,
    import java.awt.Window;
    import javax.swing.JInternalFrame;
    import javax.swing.event.InternalFrameAdapter;
    import javax.swing.event.InternalFrameEvent;
    public class TopLevelDesktop extends javax.swing.JFrame {
        private static final long serialVersionUID = 1L;
        private javax.swing.JDesktopPane desktopPane;
        private javax.swing.JPanel jPanel1;
        private javax.swing.JButton newSimpleInternalWindow;
        private javax.swing.JButton gcButton;
        private javax.swing.JLabel maxMemory;
        private javax.swing.JLabel totalMemory;
        private javax.swing.JLabel usedMemory;
        private javax.swing.JLabel freeMemory;
        public TopLevelDesktop() {
            setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
            setMinimumSize(new java.awt.Dimension(400, 300));
            jPanel1 = new javax.swing.JPanel();
            jPanel1.setLayout(new javax.swing.BoxLayout(jPanel1, javax.swing.BoxLayout.Y_AXIS));
            desktopPane = new javax.swing.JDesktopPane();
            newSimpleInternalWindow = new javax.swing.JButton();
            newSimpleInternalWindow.setText("New Internal Window");
            newSimpleInternalWindow.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    final JInternalFrame internalFrame = new JInternalFrame("Hi", true, true, true, true);
                    internalFrame.setDefaultCloseOperation(JInternalFrame.DISPOSE_ON_CLOSE);
                    internalFrame.addInternalFrameListener(new InternalFrameAdapter() {
                        @Override
                        public void internalFrameClosed(InternalFrameEvent e) {
                            e.getInternalFrame().getContentPane().removeAll();
                            e.getInternalFrame().getContentPane().requestFocusInWindow();
                            remWins(internalFrame);
                            Runtime runtime = Runtime.getRuntime();
                            long total = runtime.totalMemory();
                            long free = runtime.freeMemory();
                            long max = runtime.maxMemory();
                            long used = total - free;
                            System.out.println("Remove new JInternalFrame : " + Math.round(max / 1e6) + " MB available");
                            System.out.println("Remove new JInternalFrame : " + Math.round(total / 1e6) + " MB allocated");
                            System.out.println("Remove new JInternalFrame : " + Math.round(free / 1e6) + " MB free");
                            System.out.println("Remove new JInternalFrame : " + Math.round(used / 1e6) + " MB used");
                    internalFrame.getContentPane().add(new SimplePanel());
                    internalFrame.pack();
                    internalFrame.setVisible(true);
                    desktopPane.add(internalFrame);
                    Runtime runtime = Runtime.getRuntime();
                    long total = runtime.totalMemory();
                    long free = runtime.freeMemory();
                    long max = runtime.maxMemory();
                    long used = total - free;
                    System.out.println("Add new JInternalFrame : " + Math.round(max / 1e6) + " MB available");
                    System.out.println("Add new JInternalFrame : " + Math.round(total / 1e6) + " MB allocated");
                    System.out.println("Add new JInternalFrame : " + Math.round(free / 1e6) + " MB free");
                    System.out.println("Add new JInternalFrame : " + Math.round(used / 1e6) + " MB used");
            jPanel1.add(newSimpleInternalWindow);
            gcButton = new javax.swing.JButton();
            gcButton.setText("Run Garbage Collection");
            gcButton.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    Runtime runtime = Runtime.getRuntime();
                    runtime.gc();
                    long total = runtime.totalMemory();
                    long free = runtime.freeMemory();
                    long max = runtime.maxMemory();
                    long used = total - free;
                    maxMemory.setText(Math.round(max / 1e6) + " MB available");
                    totalMemory.setText(Math.round(total / 1e6) + " MB allocated");
                    freeMemory.setText(Math.round(free / 1e6) + " MB free");
                    usedMemory.setText(Math.round(used / 1e6) + " MB used");
                    System.out.println("Add new JInternalFrame : " + Math.round(max / 1e6) + " MB available");
                    System.out.println("Add new JInternalFrame : " + Math.round(total / 1e6) + " MB allocated");
                    System.out.println("Add new JInternalFrame : " + Math.round(free / 1e6) + " MB free");
                    System.out.println("Add new JInternalFrame : " + Math.round(used / 1e6) + " MB used");
            jPanel1.add(gcButton);
            maxMemory = new javax.swing.JLabel();
            totalMemory = new javax.swing.JLabel();
            usedMemory = new javax.swing.JLabel();
            freeMemory = new javax.swing.JLabel();
            jPanel1.add(maxMemory);
            jPanel1.add(totalMemory);
            jPanel1.add(usedMemory);
            jPanel1.add(freeMemory);
            getContentPane().add(jPanel1, java.awt.BorderLayout.WEST);
            getContentPane().add(desktopPane, java.awt.BorderLayout.CENTER);
            pack();
        public static void main(String args[]) {
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    new TopLevelDesktop().setVisible(true);
        public void remWins(JInternalFrame internalFrame) {
            Window[] w;
            w = Window.getOwnerlessWindows();
            int n = 0;
            n = w.length;
            if (n > 1) {
                for (int i = 2; i <= w.length;) {
                    w[i - 1].setVisible(false);
                    i++;
            n = 0;
            n = internalFrame.getComponentCount();
            if (n > 0) {
                //Component[] a = panel.getComponents();
                 /*Component[] components = panel.getComponents();
                String compName = "";
                for (int i = 0, l = components.length; i < l; i++) {
                /*if (components[i] instanceof JButton) {
                JButton button = (JButton) components;
    if (button.hasFocus()) { // from which component
    String btnMane = button.getName();
    } else if (components[i] instanceof JComboBox) {
    } else if (components[i] instanceof JTextField) {
    } else if (components[i] instanceof JTable) {
    } else if (components[i] instanceof JScrollPane) {
    } else */
    /*if (components[i] instanceof JPanel) {
    JPanel pnl = (JPanel) components[i];
    compName = pnl.getName();
    compName = pnl.getUIClassID();
    compName = pnl.toString();
    int n1 = 0;
    n1 = pnl.getComponentCount();
    if (n > 0) {
    Component[] components1 = pnl.getComponents();
    String compName1 = "";
    for (int i1 = 0, l1 = components1.length; i1 < l1; i1++) {
    /*if (components[i] instanceof JButton) {
    JButton button = (JButton) components[i];
    if (button.hasFocus()) { // from which component
    String btnMane = button.getName();
    } else if (components[i] instanceof JComboBox) {
    } else if (components[i] instanceof JTextField) {
    } else if (components[i] instanceof JTable) {
    } else if (components[i] instanceof JScrollPane) {
    } else */
    /*if (components1[i1] instanceof JPanel) {
    JPanel pnl1 = (JPanel) components1[i1];
    compName1 = pnl1.getName();
    compName1 = pnl1.getUIClassID();
    compName1 = pnl1.toString();
    pnl1 = null;
    pnl = null;
    internalFrame.removeAll();
    Runtime runtime = Runtime.getRuntime();
    long total = runtime.totalMemory();
    long free = runtime.freeMemory();
    long max = runtime.maxMemory();
    long used = total - free;
    System.out.println("Remove new JInternalFrame : " + Math.round(max / 1e6) + " MB available");
    System.out.println("Remove new JInternalFrame : " + Math.round(total / 1e6) + " MB allocated");
    System.out.println("Remove new JInternalFrame : " + Math.round(free / 1e6) + " MB free");
    System.out.println("Remove new JInternalFrame : " + Math.round(used / 1e6) + " MB used");
    hint inside remWins, plus minus citiBus                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Tracing Garbage Collection

    I need to implement a program illustrating the performance loss to java through the automated garbage collection Vs controlling the garbage collection manually using java real time programming.
    How can I determine when garbage collection is performed by the virtual machine? For instance could I launch a thread to monitor the garbage collection and return feedback when collection is in progress?
    Thanks

    I have been using this method on my object to write to a file.
    protected void finalize() throws RemoteException {
    try{
    Date now = new Date();
    String s = "Garbage Collection was here\n Date: "+now + " Object: " + this.getName()+"\n";
    byte abyte0[] = s.getBytes();
    FileOutputStream fileoutputstream = new FileOutputStream("garbageplanner.txt", true);
    fileoutputstream.write(abyte0);
    fileoutputstream.close();
    }catch (Exception e){}
    }

  • Oracle JVM Garbage Collection not executing

    I am experiencing a problem with garbage collection when running a java stored procedure in an 9.2.0.3.0 Oracle database running on a Windows 2k computer.
    I have created a simple java class that represents a tree structure. Each instance of the class has a reference to it's parent and a Vecotor of all it's children. Each instance also has a Vector to hold name value pairs. I ran a program that creates 30 instances with 50 children each for a total of 1500 instances. Each instance has 30 properties(name value pairs).
    By using the debugger in JDeveloper and breakpoints I can watch the javaw.exe process's use of RAM.
    Start up: 6,788mb
    After creation of 1500 instances: 17,720
    After releasing all objects and calling System.gc(): 7,156
    I deploy the package to my Oracle database and perform the exact same routine using breakpoints and test procedures in plsql Developer. Using the breakpoints and watching the oracle.exe process's use of RAM I see:
    Start up: 81,116mb
    After creation of 1500 instances: 94,952
    After releasing all objects and calling System.gc(): 95,036
    When run in Oracle the resources are not released. Is there somthing special that needs to be called to get the garbage collector to do it's job when running in an Oracle database?
    Execution Instructions and source:
    run app.main from jdeveloper and app.main2 as a plsql stored procedure. I have included my test procedure at the end and the plsql stored procedure package declarations. I used debuggers and breakpoints to watch the process, there is probably a way to do this by outputting the current memory being used by I didn't know how. If you use debuggers and breakpoints then when running in JDeveloper put your breakpoints on the 3 assignments of breakpointVar in SimpleClass.main(...). When running the stored procedure test block put them on the 3 assignments of breakpoint_var in there.
    package mypackage2;
    public class app {
    private static SimpleClass topObject;
    public static void main(String[] args) {
    int breakpointVar;
    breakpointVar = 0;
    main2(30, 50);
    breakpointVar = 1;
    release();
    breakpointVar = 2;
    public static void main2(int numParents, int numChildren){
    SimpleClass temp;
    SimpleClass child;
    topObject = new SimpleClass();
    for(int i = 0; i < numParents; i ++){
    temp = new SimpleClass();
    addProperties(temp, 30);
    topObject.addChild(temp);
    for(int j = 0; j < numChildren; j++){
    child = new SimpleClass();
    addProperties(child, 30);
    temp.addChild(child);
    public static void release(){
    topObject.releaseAllDecendents();
    topObject.release();
    System.gc();
    private static void addProperties(SimpleClass toAddTo, int numProps){
    cimxProperty toAdd;
    for(int i = 0; i < numProps; i ++){
    toAdd = new cimxProperty("prop "+i,"value "+i);
    toAddTo.addProperty(toAdd);
    package mypackage2;
    import java.util.Vector;
    public class SimpleClass {
    private Vector _children;
    private Vector _props;
    private SimpleClass _parent;
    public SimpleClass() {
    _children = new Vector(10, 5);
    _props = new Vector(10, 5);
    _parent = null;
    public void addChild(SimpleClass toAdd) {
    toAdd._parent = this;
    _children.add(toAdd);
    public SimpleClass getChild(int index){
    return (SimpleClass)_children.get(index);
    public void addProperty(cimxProperty toAdd){
    _props.add(toAdd);
    public cimxProperty getProperty(int index) {
    return (cimxProperty)_props.get(index);
    public void releaseAllDecendents()
    SimpleClass temp;
    //remove all references to the the parent object from the children.
    for(int i = 0; i < _children.size(); i ++)
    temp = (SimpleClass)this._children.get(i);
    temp.releaseAllDecendents();
    temp._parent = null;
    temp._props.clear();
    temp._children.clear();
    temp = null;
    this._children.clear();
    public void release() {
    this._parent = null;
    this._children.clear();
    this._props.clear();
    package mypackage2;
    public class cimxProperty
    private static String _dateFormat = "MM/DD/YYYY HH:MI:SS";
    private String name;
    private String value;
    private String dataType;
    public cimxProperty()
    name = "";
    value = "";
    dataType = "";
    public cimxProperty(String Name, String Value)
    name = Name;
    value = Value;
    dataType = "UNKNOWN";
    public cimxProperty(String Name, String Value, String DataType)
    name = Name;
    value = Value;
    dataType = DataType;
    public String toString()
    return name + "["+dataType + "]: " + value;
    public void setName(String name)
    this.name = name;
    public String getName()
    return name;
    public void setValue(String value)
    this.value = value;
    public String getValue()
    return value;
    public void setDataType(String DataType)
    this.dataType = DataType;
    public String getDataType()
    return dataType;
    CREATE OR REPLACE PACKAGE JAVA_MEMORY_TEST AUTHID CURRENT_USER AS PROCEDURE release; PROCEDURE main2(p_num_parents IN NUMBER, p_num_children IN NUMBER); END JAVA_MEMORY_TEST;
    CREATE OR REPLACE PACKAGE BODY JAVA_MEMORY_TEST AS PROCEDURE release AS LANGUAGE JAVA NAME 'mypackage2.app.release()'; PROCEDURE main2(p_num_parents IN NUMBER, p_num_children IN NUMBER) AS LANGUAGE JAVA NAME 'mypackage2.app.main2(int, int)'; END JAVA_MEMORY_TEST;
    declare
    number breakpoint_var
    begin
    -- Call the procedure
    breakpoint_var := 0;
    java_memory_test.main2(30, 50);
    breakpoint_var := 1;
    java_memory_test.release();
    breakpoint_var := 2;
    end;

    When run in Oracle the resources are not released. Is there somthing special that needs to
    be called to get the garbage collector to do it's job when running in an Oracle database?Curious - I was always under the impression that you can not force garbage collection. All you could do was request it, and the JVM was free to do that when it was "good 'n ready", usually in a separate thread.
    I gather this from the API docs for system.gc() where it says "Calling this method suggests that the Java virtual machine expend effort ..." and the word "suggests" imlies that it is not required to run.

  • How can I prevent class garbage collection????

    Hi,
    Is there a way to prevent a class from being garbage collected without using the -noclassgc option? Is there some code I can include in a class that tells the JVM not to garbage collect that particular class?
    Thanks in advance,
    Jacob.

    The code shown below (slightly modified from yours) should work correctly on any 1.0.x throught 1.4 JVM.
    Look at this article for further info: http://www.javaworld.com/javaworld/javatips/jw-javatip52.html
    public class SQLManager extends PoolManager {
        private static SQLManager myself;
        //code.........................
        public static SQLManager getInstance() {
            // This version of a getInstance method suffers from the use of the
            // broken (unreliable) double checked locking idiom.  It should never
            // be used on a system with more than one processor and is ill-advised
            // any other time.  It can  lead to accesses to uninitialized objects.
            // See http://www.javaworld.com/javaworld/jw-02-2001/jw-0209-double.html
            // or http://c2.com/cgi/wiki?DoubleCheckedLockingIsBroken
            // So despite its common appearance in books and pattern repositories,
            // it should not be used.
            if (myself == null) {
                synchronized(SQLManager.class) {
                    if (myself == null)
                        myself = new SQLManager();
            return myself;
        private SQLManager() {
            livethread();
            //code.........................
        void livethread()
            System.out.println("##############################################################");
            System.out.println("###################Live Thread called#########################");
            System.out.println("##############################################################");
            Thread thread = new Thread()
                public void run()
                    // added this code to ensure that run() actually is getting
                    // called
                    System.out.println("##############################################################");
                    System.out.println("#################### Thread Started ##########################");
                    System.out.println("##############################################################");
                    Class myClass = SQLManager.class;
                    while (true)
                        try
                            synchronized (myClass)
                                myClass.wait();
                        catch (InterruptedException ex)
                            System.out.println("##############################################################");
                            System.out.println("###################Thread interrupted#########################");
                            System.out.println("##############################################################");
                        finally
                            System.out.println("##############################################################");
                            System.out.println("################### Something Happened #########################");
                            System.out.println("##############################################################");
                    System.out.println("##############################################################");
                    System.out.println("#################### Thread Dead?? ##########################");
                    System.out.println("##############################################################");
            thread.setDaemon(true);
            System.out.println("##############################################################");
            System.out.println("#################### Starting Thread #########################");
            System.out.println("##############################################################");
            thread.start();
        //code.........................
    }

  • Which algirithm is being used by java runtime for garbage collection??

    On what basis does java reclaim objects using Garbage Collection ??
    and explain the method i.e the step by step basis on how it is being done??

    There are various whitepapers and the like on this.
    As far as which objects may be collected, it's just any object that isn't referred to - directly or indirectly - by one of the root set of threads in the JVM.
    Collecting algorithms vary from jvm to jvm. You'd do better to search the web for a whitepaper on the subject.
    ~Cheers

  • High Eden Java Memory Usage/Garbage Collection

    Hi,
    I am trying to make sure that my Coldfusion Server is optomised to the max and to find out what is normal limits.
    Basically it looks like at times my servers can run slow but it is possible that this is caused by a very old bloated code base.
    Jrun can sometimes have very high CPU usage so I purchased Fusion Reactor to see what is going on under the hood.
    Here are my current Java settings (running v6u24):
    java.args=-server -Xmx4096m -Xms4096m -XX:MaxPermSize=256m -XX:PermSize=256m -Dsun.rmi.dgc.client.gcInterval=600000 -Dsun.rmi.dgc.server.gcInterval=600000 -Dsun.io.useCanonCaches=false -XX:+UseParallelGC -Xbatch ........
    With regards Memory, the only memory that seems to be running a lot of Garbage Collection is the Eden Memory Space. It climbs to nearly 1.2GB in total just under every minute at which time it looks like GC kicks in and the usage drops to about 100MB.
    Survivor memory grows to about 80-100MB over the space of 10 minutes but drops to 0 after the scheduled full GC runs. Old Gen memory fluctuates between 225MB and 350MB with small steps (~50MB) up or down when full GC runs every 10 minutes.
    I had the heap set to 2GB initally in total giving about 600MB to the Eden Space. When I looked at the graphs from Fusion Reactor I could see that there was (minor) Garbage Collection about 2-3 times a minute when the memory usage maxed out the entire 600MB which seemed a high frequency to my untrained eye. I then upped the memory to 4GB in total (~1.2GB auto given to Eden space) to see the difference and saw that GC happened 1-2 times per minute.
    Is it normal in Coldfusion that the Eden memory would grow so quickly and have garbage collection run so often? i.e do these graphs look normal?
    Also should I somehow redistribute the memory available to give the Eden memory more since it seems to be where all the action is?
    Any other advice for performance improvements would be much appreciated.
    Note: These graphs are not from a period where jrun had high CPU.
    Here are the graphs:
    PS Eden Space Graph
    PS Survivor Space Graph
    PS Old Gen Graph
    PS Perm Gen Graph
    Heap Memory Graph
    Heap/Non Heap Memory Graph
    CPU Graph
    Request Average Execution Time Graph
    Request Activity Graph
    Code Cache Graph

    Hi,
    >Is it normal in Coldfusion that the Eden memory would grow so quickly and have garbage collection run so often?
    Yes normal to garbage collect Eden often. That is a minor garbage collection.
    >Also should I somehow redistribute the memory available to give the Eden memory more since it seems to be where all the action is?
    Sometimes it is good to set Eden (Eden and its two Survivor Spaces combined make up New or Young Generation part of JVM heap) to a smaller size. I know your thinking - what make it less, but I want to make it bigger. Give less a try (sometimes less = more, bigger not = better) and monitor the situation. I like to use -Xmn switch, some sources say to use other method/s. Perhaps you could try java.args=-server -Xmx4096m -Xms4096m -Xmn172m etc. I better mention make a backup copy of jvm.config before applying changes. Having said that now you know how you can set the size to bigger if you want.
    I think the JVM is perhaps making some poor decisions with sizing the heap. With Eden growing to 1Gb then being evacuated not many objects are surviving and therefore not being promoted to Old Generation. This ultimately means the object will need to be loaded again latter to Eden rather than being referenced in the Old generation part of the heap. Adds up to poor performance.
    >Any other advice for performance improvements would be much appreciated.
    You are using Parallel garbage collector. Perhaps you could enable that to run multi-threaded reducing the time duration of the garbage collections, jvm args ...-XX:+UseParallelGC -XX:ParallelGCThreads=N etc where N = CPU cores (eg quad core = 4).
    HTH, Carl.

  • Memory leak in java / forcing garbage collection for unused resource?

    Is there any possibility in big programs if not designed properly for leakage of memory?
    If say i forget to force garbage collection of unused resouces what will happen?
    Even if i am forcing garbage collection how much assurity can be given to do so?
    I need answers w.r.t typical programming examples if someone can provide i will be happy.
    Or any useful link.
    Thanks
    Vijendra

    Memory leaks are usually much related with C/C++ programming since in that language you have direct access to memory using pointers.
    Now, in Java you do not have access to pointers, however you could still tie up your objects in a way that the garbage collection can not remove them.
    Basically, the grabage collection will search all the object implementation, and see if they are referenced or not. If not it will free that memory. However if you, somehow in you code allow a reference to your object then the garbage collection will not displose of that object.
    An example I can think of is when developing web applications. For example storing objects in the session will mean that you will have a reference to the object from the session, therefore the garbage collection will not free up the meomry taken by those objects untill the session has expired.
    That is how I know it... at least that is how they tought it to me!
    regards,
    sim085

  • Use Garbage Collection Liberary  in C++ application

    I knew that Garbage Collection liberary was implemented using C++
    Can I use it when I write C++ application to avoid any memory leak happens in my application.

    pm_kirkham wrote:
    -Kayaman- wrote:
    kavon89 wrote:
    pm_kirkham wrote:
    James_Vagabond wrote:
    morgalr wrote:... Java with C syntax.You make it sound as if garbage collection is a Java thing. In fact it was in the earliest OO programming language. See Simula
    You make it sound as if garbage collection is an OO thing. In fact it was in the second oldest programming language. See LISP
    You make it sound as if garbage collection is a computer thing. In fact it pre-dates computers. See [Waste collector|http://en.wikipedia.org/wiki/Waste_collector] .
    You make it sound as if collection is a garbage thing. In fact it pre-dates waste management. See [Tax collector|http://en.wikipedia.org/wiki/Tax_collector].
    You make it sound as if collecting stuff together is a human thing. In fact it is instrumental in aggregating a dust cloud into stars and planets. See the [formation of the solar system|http://en.wikipedia.org/wiki/Formation_and_evolution_of_the_Solar_System].
    So that's what we are; just garbage on the heap?

  • 11.5.10.2 & Sun T5220 & threads & Java garbage collection...

    We recently upgraded our prod and test servers (middle tier) to Sun T5220's each with 8 procs which have 8 cores per proc. Apache/Java sees that as having 64 CPUs and configures a garbage collection thread for each. Since we have around 10 test and dev instances for the HRMS the apps instances alone, (we also have several Financials instances on the same server), it was kicking off over 640 threads of garbage collection! Needless to say the contention was overloading the server causing major hassles. We have since updated each $CONTEXT_FILE ADJREOPTS and ADJRIOPTS settings to only kick off 2 threads per instance. This has helped, but we still have issues, especially when running adadmin or adpatch and if we give it more than 8 workers. Has anyone else seen this, and if so, have you had any other solution(s)?
    We are also seeing strange behavior with FNDSM. Unlike the production server, which has much less load in some respects, on the test sever, each apps instances instance of FNDSM is restarting several times a day for no apparent reason and leaving many defunct child processes. We do see a slight hangup in the tnsping to the FNDSM_<server> listener every so often, but never anything long enough that it should be an issue. We also have multiple NICs on the box, but again, that has never been an issue before.
    Anyone else out there using Suns T5220s? Anyone else having any issue(s) with Apache/Java and / or FNDSM?
    thanks,
    -mike

    It appears to be a known issue for the Niagara chips:
    Oracle Applications Installation and Upgrade Notes Release 12 (12.0.4) for Solaris Operating System (SPARC)
    http://metalink.oracle.com/metalink/plsql/ml2_documents.showDocument?p_database_id=NOT&p_id=402312.1
    Java Performance on UltraSPARC T1/T2 (Niagara) processors
    There is a known issue with the Java Runtime Environment (JRE) version 5 on Sun's Niagara processor, a one-socket 8 core processor that can run 32 threads in parallel. As the JRE treats the Niagara system as a server class machine, the server appears to the JRE to be a 32-CPU machine and each Java Virtual Machine (JVM) spawns 32 garbage collector threads. Also, newer chips support a larger number of threads (for example, the Niagara 2 will appear as a 64-way server).

  • Managing gigabytes with Java garbage collection ?

    I am at the early stage of Java development project (kind of a memory based database index server) which easily involves managing 500.000+ very large Java objects (array based as this is the only way to use memory efficiently in Java) + a couple of millions of smaller objects.
    Most of the objects are long lived but some (query) operations involve temporary creation of several 100MB+ sized objects. The app should run on Windows or Unix\Linux and will probably require/use up to 1-2GB of RAM (max possible on typical 32bit OS). At best it should be able to run under the JDK1.3+ hotspot VM.
    I am concerned that the garbage collection by the VM may be a problem. While the app does not have real-time requirements, most (query) operations ought to complete in less than a second. Frequent complete GC freezes of say 5+ seconds would not be acceptable.
    Anyone with experience on this ? Do you expect that I will get a problem with Java garbage collection or am I too concerned about this ?

    Anyone with experience on this ? Do you expect that I
    will get a problem with Java garbage collection or am
    I too concerned about this ?With an application that size, yes, you will run into problems, unless you are very careful.
    Not being familiar with your applications memory allocation and access patterns, it's hard to be more specific. Perhaps something like 1.4.1's incremental GC will help in your case, but simply getting the VM to allocate and manage 2GB of memory will be a challenge.
    Caveat emptor..
    (See if you can split your application into smaller applications that can be run in different virtual machines; as long as each application's virtual machine doesn't grow too large, the GC problem will be manageable, and more importantly, you'll be able to use more than 2GB of memory comfortably).

Maybe you are looking for

  • ICal on the Mac does not sync all entries

    I have several entries on my MacBook that do not show up after the syncing thru iTunes. I have told iTunes to replace my calendar on the iPhone with the one on my Mac. Didn't solve the problem. I only have one calendar ie Main I have reset syncing th

  • Reject Purchase order using abap OO class CL_PO_HEADER_HANDLE_MM

    Hi all, We have created a webdynpro application for maintaining purchase order by using class CL_PO_HEADER_HANDLE_MM. With this class we are able to release (method RELEASESTATE_MM~RELEASE)  or cancel release.. We are trying, in vain,  to reject purc

  • Will Aperture allow me to search photos by title on an iPad?

    Will Aperture allow me to search photos by title on an iPad? iPhoto library does not let me search for photos by name. Thanks for your help and any suggestions.  Rob

  • Patch for V2.0

    Is there a patch for APEX V2.0? if so where is it? thanks Paul P

  • Third Party Sick Pay

    Can some one help me with a document/steps for the right way to configure Third Party Sick Pay in SAP? Regards Ranjani