Redirect garbage collector output to a historical file

Hello to you all,
I know how to redirect the garbage collector output to a file with the parameter -Xloggc:<file> but there is a problem: Everytime the jvm is rebooted, that file is reset, deleting all the information generated before.
I would like the jvm to append the new information to that file instead of deleting the old one.
Is there anyway to configure the jvm to do that?

Hi you all again,
Probably I didn't explain my problem correctly in the previous post.
I'm using J2SDK 1.4.1_02 on a Windows 2K SP1 platform .
I've read the JVM documentation and I've learnt a lot about tuning garbage collection but almost nothing about how to solve the problem I have.
I know how to generate the verbosegc output with the parameter '-verbosegc' and how to redirect it to a file with the parameter '-Xloggc:<file>' but everytime the JMV is restarted the content of that file is deleted.
Is it possible to append content to that file instead of overwriting it and can anyone give me a clue to do this?
Thank you in advance.

Similar Messages

  • Understanding garbage collector output

    Hi all.
    My application uses an increasing amount of memory, and in order to solve the problem I have turned on the -verbosegc option. The output is as follows:
    <GC: managing allocation failure: need 1040 bytes, type=1, action=1>
    <GC: 504 milliseconds since last GC>
    <GC: freed 6530 objects, 288432 bytes in 10 ms, 35% free (661616/1887424)>
      <GC: init&scan: 1 ms, scan handles: 7 ms, sweep: 2 ms, compact: 0 ms>
      <GC: 4 register-marked objects, 7 stack-marked objects>
      <GC: 8 register-marked handles, 136 stack-marked handles>
      <GC: refs: soft 0 (age >= 32), weak 0, final 1, phantom 0>
    <GC: managing allocation failure: need 1040 bytes, type=1, action=2>
    <GC: 10 milliseconds since last GC>
    <GC: expanded object space by 1048576 to 2936000 bytes, 58% free>
    <GC: need to expand mark bits to cover 2560 bytes>Is any one able to explain this output for me? My problem is that the object space is expanded regularly and eventually the garbage collector writes "totally out of heap space" and an OutOfMemoryError occurs.
    My -version is
    java version "1.3.0"
    Java(TM) 2 Runtime Environment, Standard Edition
    Classic VM (build 1.3.0-1, native threads, jit)running on UNIX, Digital Alpha.
    Regards,
    Torben Lange

    Just a follow up on my memory leak problem which I have solved now.
    I had created a class which handles database connections. The constructor looked something like this:
    Connection connection;
    public DBConnection() {
      DriverManager.registerdriver(new myDriver());
      connection = DriverManager.getConnection(...);
    }My application creates an object of this class, uses it and then closes the object. This goes on all the time. (Yes, it could be handled another way by pooling database access or simply keep the connection open without closing it - but it isn't.)
    It seems that the registration of the driver in the constructor eventually will fill the memory - apparently the same driver is registered several times.
    Problem was solved when changing the code into the following:Connection connection;
    static boolean isRegistered = false;
    public DBConnection() {
      if (! isRegistered) {
        DriverManager.registerdriver(new myDriver());
        isRegistered = true;
      connection = DriverManager.getConnection(...);
    }Hope this could help others in the same situation.
    Regards,
    Torben Poort Lange

  • Logging Garbage collector for an OC4J with 2JVM

    Hi, I have one OC4J with two JVM setted.
    If I put -verbose:gc it logs in the std Output file.
    I trying to log the garbage collector in two different file each one for one JVM.
    Anyone as an idea?

    Don't create massive amounts garbage memory. It's that simple. You should try to limit the creation of memory inside your animation loop. If there is a process inside the loop that creates memory, there is definitely some way to create that item staticly, rather than allocating new memory with each iteration. There shouldn't be any kind of problem that would involve the creation of THIS much memory, and it's deallocation. If you read about how the garbage collector is implemented, you'll notice that it stores all of it's memory on a single conveyor belt. This is for ALL memory in the program. Therefor once the garbage collector has gone through and marked all of the memory that needs to be reclaimed, it performs it's sweep and must feeze the entire program because that conveyor belt can not be manipulated while it's re-arranging the memory. The garbage collector will eliminate MOST memory leaks, but it does not eliminate any thought on the part of the programmer about memory.
    -Jason Thomas.

  • How to get the garbage collector to work?

    Hi,
    i have i program where i load an image scale it down and save the scaled version in an array. I do this for a whole directory of images.
    After every image i set the temporary variable for the loaded image = null and call the function System.gc().
    My problem is, that the garbage collector does�nt give the memory of the loaded image free and the used memory of my program grows with every loaded image.
    /* Reads all images from a folder an stores them in an Array of images */
         public static BufferedImage[] readScaledImagesFromFolder(String folder,
                   int maxSize) {
              File dir = new File(folder);     /* Open the Folder */
              String[] children = dir.list();          /* Get the children of the folder */
              if (children == null) {
                 // Either dir does not exist or is not a directory
                  System.out.println("No images in the folder!");
                  return null;
             } else {
                  /* Init array for images */
                  BufferedImage[] images = new BufferedImage[children.length];     
                  int i = 0;
                  int index = 0;
                  BufferedImage temp;
                  String filename, fileending;
                 for (i=0; i<children.length; i++) {
                      // Get filename of file or directory
                     filename = children;
         /* Get the fileending of the file */
         fileending = filename.toLowerCase().substring(filename.length()-4);
         if(fileending.equals(".jpg") || fileending.equals(".bmp")
                   || fileending.equals(".png") || fileending.equals(".gif"))
              /* Read the image */
              temp = util.ImageUtils.loadBufferedImage(folder+"/"+filename);
              /* Scale the image down and save it in an array */
              images[index] = Util.getScaledImage(temp,maxSize);
              index++;          
         temp = null;
         System.gc();
         Mosaic.sourceImageNum = index;
         System.out.println((index+1)+" resized pictures loaded from folder: "+folder);
         return images;     
    How can i get the gargabe collector to work after every iteration?
    I tried to let the Thread.sleep(10) after System.gc() but it does�nt help.
    Thank you every much
    JackNeil

    Hm yes.. i now that System.gc() is only a
    suggestion.
    But i know what my program is doing and that it
    does�nt need the temporary image anymore after i have
    a scaled down version. And the temporay image will become unreachable as soon as reading the next one overwrites your temp variable. Setting the variable to null doesn't have much effect.
    It would be smarter to load the new image over the
    old temporary image and not to expand the heapsize to
    maximum.Then look at the possibitly of loading the next image into the same bufferedimage.

  • Garbage collector don't works.

    Hello people !
    When I restart the weblogic server this do not shows the lastest change that I made. I think the problem is related to the garbage collector and its bean tree.
    Do you known how to solve this?
    Thank you.
    Regards.

    I'm working with WebLogic Server 10.0 and the problem is if I restart the server this don't holds the lastest change that I made, it happens with any type of change (deploy, undeploy, create or delete servers/services, etc).
    I've reviewed the log file and I've found the following error:
    <Jun 2, 2008 6:45:14 PM CDT> <Warning> <Management> <BEA-141269> <The temporary bean tree updateDeploymentContext(Mon Jun 02 10:46:11 CDT 2008) was allocated for an undo, get, or activate operation, but has not been garbage collected.>
    Stopping PointBase server...
    PointBase server stopped.
    Thank you for your attention

  • Clear method and Garbage Collector

    Hi Gurus,
    Does the Clear method (hashtable, vector etc..) is a good option for garbage collection ?
    In other words, if I have a vector V with 100 elements and I perform a V.clear(), am I sure that the 100 elements are now candidates for the Garbage Collection ?
    Or is it better to write a loop performing a NULL assignment for each element of the vector ?

    Hi schapel,
    I know it's not a good idea to force the garbage collector, but let me explain what I am confronted with.
    (FYI, I didn't write the source code. Comes from a 3rd party)
    The aim is to build a jsp page which is the list of the files contained in a web server directory.
    I have a "Directory" class, and a "File" class. To build the jsp, each directory of the webserver is represented by a directory class, and each file, ...by a file class.
    To simplify, when the tree structure of the web server is build in memory, I create a jsp page to list the files, and then, I do not need the vector anymore. But the vector can be quite huge and each client will build his own vector at the begening of his session (and will never use it again during the session).
    Don't you think it's usefull in that situation to free some memory ?

  • I have a memory leak, objective-c 2.0, and garbage collector...

    the code i am using is a modification of the code/problem found in "Cocoa with Objective-C", chapter 3.
    i have tried to use the objective-c 2.0 garbage collector methodology, using @property, @synthesize, etc. when i run the code as listed below i get a leaking message.
    [Session started at 2008-02-01 23:33:37 -0500.]
    2008-02-01 23:33:38.070 SongsFoundationTool[28876:10b] * _NSAutoreleaseNoPool(): Object 0x2040 of class NSCFString autoreleased with no pool in place - just leaking
    Stack: (0x96b10178 0x96a3e0f8)
    2008-02-01 23:33:38.075 SongsFoundationTool[28876:10b] Song 1: We Have Exposive
    2008-02-01 23:33:38.076 SongsFoundationTool[28876:10b] * _NSAutoreleaseNoPool(): Object 0x2060 of class NSCFString autoreleased with no pool in place - just leaking
    Stack: (0x96b10178 0x96a3e0f8)
    2008-02-01 23:33:38.078 SongsFoundationTool[28876:10b] Song 2: Loops of Fury
    The Debugger has exited with status 0.
    when i include the commented out section, in the implementation file section, the description method, and use song1 and song2, in main, instead of song1.name and song2.name the program seems to run fine.
    The Debugger has exited with status 0.
    [Session started at 2008-02-01 23:38:24 -0500.]
    2008-02-01 23:38:24.375 SongsFoundationTool[28936:10b] Song 1: We Have Exposive
    2008-02-01 23:38:24.379 SongsFoundationTool[28936:10b] Song 2: Loops of Fury
    The Debugger has exited with status 0.
    please help me understand what's happening here.
    also, why was it necessary to use
    @property(copy, readwrite) NSString *name;
    @property(copy, readwrite) NSString *artist;
    instead of
    @property(readwrite) NSString *name;
    @property(readwrite) NSString *artist;
    thanks everyone, the code is below.
    // ....................... header file ...............
    #import <Cocoa/Cocoa.h>
    @interface Song : NSObject {
    NSString *name;
    NSString *artist;
    @property(copy, readwrite) NSString *name;
    @property(copy, readwrite) NSString *artist;
    @end
    //.................... the implementation file ..................
    #import "Song.h"
    @implementation Song
    @synthesize name;
    @synthesize artist;
    -(NSString *) description
    return [ self name ];
    @end
    //................................ main............................
    #import <Foundation/Foundation.h>
    #import "Song.h"
    int main (int argc, const char * argv[]) {
    Song *song1 = [ [ Song alloc ] init ];
    song1.name= @"We Have Exposive" ;
    [ song1 setArtist: @"The Future Sound Of Londown" ];
    Song *song2 = [ [ Song alloc ] init ];
    [ song2 setName: @"Loops of Fury" ];
    [ song2 setArtist: @"The Chemical Brothers" ];
    // Display Object
    NSLog( @"Song 1: %@", song1.name );
    NSLog( @"Song 2: %@", song2.name );
    // include statements below if -description method is uncommented
    // then comment out the two statements above. no memory leak if the code
    // is used from the statements below and - description is not commented out and
    // the two NSLog statements above are commented out.
    NSLog( @"Song 1: %@", song1 );
    NSLog( @"Song 2: %@", song2 );
    return 0;
    }

    Normally, your main only has a call to NSApplicationMain(). If you aren't doing a traditional MacOS X application, you will still want at least NSApplicationLoad() to get enough of the runtime to avoid those messages.
    I don't know for sure about the syntax of Objective-C 2.0. That stuff is all new. What error message are you getting that indicated that (copy, readwrite) is required? Could you provide a link to the actual example source? I did a quick check and assign and readwrite are the defaults. It is possible that readwrite by itself makes no sense. But I'm just guessing.

  • Redirecting System.out and System.err to files

    Is there a way I can configure my web-appliction (in web.xml or something) to redirect all the output (.err and .out) to specific files?

    I think you could create PrinStreamS from your desired output files and then use System.setOut(<...>) and System.setErr(<...>). Place this code in a servlet that you load at startup...

  • How do I redirect System.err output in iPlanet 4.1?

    All,
    I've been trying for days to redirect System.err output from a Java program
    to a log file. I followed the instructions here:
    http://knowledgebase.iplanet.com/ikb/kb/articles/4790.html
    Unfortunately, nothing has been written to any of the log files (even though
    I have plenty of System.err.println()'s in my code).
    Anyone else get this to work correctly?
    Thanks in advance,
    --Bill                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    Hi,
    What is the product web server or application server ? If it is application
    server then I'm very sure that this output will be seen in the kjs log file in
    Unix and in the command window in Windows NT/2K, only if you have allowed the
    process to interact with desktop. Please let me know if this answers your
    question for me to help you further on this.
    Regards
    Raj
    "news.uswest.net" wrote:
    All,
    I've been trying for days to redirect System.err output from a Java program
    to a log file. I followed the instructions here:
    http://knowledgebase.iplanet.com/ikb/kb/articles/4790.html
    Unfortunately, nothing has been written to any of the log files (even though
    I have plenty of System.err.println()'s in my code).
    Anyone else get this to work correctly?
    Thanks in advance,
    --Bill                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Get Garbage Collector Details

    Hi,
    I'm using ALBPM 6.0.4 standalone on a windows 2003.
    I'm tunning the application, but when i trying to get the garbage collector details i don't get the log file.
    i already set this arguments -Xloggc:../log/engine-max-gc.log -XX:+PrintGCDetails on Additional java arguments used in startup on execution tab.
    I'm not sure if the engine takes this arguments on start up.
    i'm doing something wrong?
    Thanks in advance,
    Helios.

    See the javadocs for DatabaseMetaData class under java.sql

  • Garbage Collector blocks - weird behaviour

    Hi!
    After launching an application we ran into weird problems with the garbage collector. It's a combo of Jetty/JGroups/Helma-Application-Server and various other libraries on a RedHat 7.3 box. The problem occurs on a machine with relativly high load (~10 requests/sec) but doesn't come along with high load automatically.
    After some hours uptime the garbage collector blocks for increasingly longer intervals until the application is reachable only for seconds every few minutes. In concerns exclusivly minor GC in the new space. Each stop lasts for just 1/10000 seconds but that in a loop of 1000s times back-to-back.
    The logfile created by the -Xloggc option looks like this:
    20085.784: [GC 20085.785: [ParNew
    Desired survivor size 32768 bytes, new threshold 0 (max 0)
    : 71552K->0K(71616K), 0.0634410 secs] 380477K->312523K(511936K), 0.0639970 secs]
    Total time for which application threads were stopped: 0.0652310 seconds
    Application time: 8.7885840 seconds
    Total time for which application threads were stopped: 0.0005810 seconds
    Application time: 0.0005620 seconds
    Total time for which application threads were stopped: 0.0006080 seconds
    Application time: 0.0002630 seconds
    Total time for which application threads were stopped: 0.0004410 seconds
    Application time: 0.0001790 seconds
    Total time for which application threads were stopped: 0.0005480 seconds
    Application time: 0.0001670 seconds
    Total time for which application threads were stopped: 0.0003440 seconds
    Application time: 0.0001210 seconds
    Total time for which application threads were stopped: 0.0004450 seconds
    Application time: 0.0001590 seconds
    Total time for which application threads were stopped: 0.0004220 seconds
    Application time: 0.0002180 seconds
    20095.265: [GC 20095.265: [ParNew
    Desired survivor size 32768 bytes, new threshold 0 (max 0)
    : 71552K->0K(71616K), 0.0753260 secs] 384282K->317322K(511936K), 0.0759450 secs]
    Total time for which application threads were stopped: 0.0767720 seconds
    Application time: 0.3346050 seconds
    While the "Total time.." lines were printed, the app was unreachable. "Application time" usually marks the time the app was running between two garbage collections. It seems as if the garbage collector tries to stop the app, can't do it for whatever reason and tries again a moment later.
    We've tested any suitable garbage collector, we've tried out j2sdk1.4.2_02, j2sdk1.4.2_07, jdk1.5.0_01, jdk1.5.0_02, we've tried different machines to exclude hardware failure. It is hard to reproduce in a test environment but we've seen a few lines like above on a windows box too (no longer blocking times, tough). There aren't any OutOfMemoryErrors, the heap management looks fine. After GC about 3/4 of the heap are freed even while the above problem occurs, so we're ruling out a memory leak.
    Maybe someone here has stumbled across that problem or has any ideas what could trigger such a behaviour? After two weeks of debugging I've run out of ideas on where to look for a bug.
    Yours remotely,
    Stefan

    hi there
    Can u add -XX:+PrintHeapAtGC -XX:+PrintGC and show the portion of the log files?
    You are using the -XX:+ParNewGC? Any -XX:+UseConcMarkSweepGC?
    Also, add -XX:+DisableExplicitGC
    Hope this helps.

  • GARBAGE COLLECTOR( NOT ACTIVATING)

    I AM CERTIFIED, LEARNED IN THE COURSE THAT THE GARBAGE COLLECTOR IS A SYSTEM THREAD WHICH RUNS AND COLLECTS ALL THE UN-REFERENCED OBJECTS BUT I COULDN'T MANAGED TO ACTIVATE IT:
    THE PROBLEM IS DEFINED AS FOLLOWS:-
    1. WE KNOW THAT IF WE OVERRIDE THE FINALIZE METHOD OF AN OBJECT THEN IT IS CALLED WHEN THE SPECIFIC OBJECT IS GARBAGE COLLECTED.
    THATS WHY I OVERRIDED A CLASS'S FINALIZE METHOD AND ISSUED A PRINTLN STATEMENT
    2. THEN AT RUNTIME I INSTANTIATED THE OBJECT OF THAT PARTICULAR CLASS .
    3. I SET THE REFERENCE TO NULL.( AT RUNTIME )
    4. NOW ACCORDING TO THE DOCUMENTATION THE OBJECTED SHOULD BE GARBAGE COLLECTED AFTER SOMETIME BUT I WAITED FOR A ABOUT TEN MINUTES BUT IT ISN'T.
    PLEASE ANSWER THIS QUESTION AN IF POSSIBLE EXPLAIN THE MECHANISM BY WHICH THE FINALIZE METHOD IS CALLED AT RUNTIME
    IT SHOULD BE NOTED THAT THIS THREAD RUNS IN LOW MEMORY CONDITIONS BUT SINCE IT IS A LOW PRIORITY THREAD HOW CAN IT MANAGES TO RUN IN LOW MEMORY CONDITIONS

    The only purpose finalize should be used for is a last ditch effort to free resources other than memory allocation. That said...
    -It should NEVER be used to free a resource that is not automatically freed when the application exits. So for example it could be used to close a socket, but it should not exist when the 'resource' is a file.
    -It should NEVER be the only way to free a resource. There is a reason I said "last ditch". The user of the object should have an explicit method to call which frees the resources.
    And that said I would never use it regardless even for a last ditch cleanup. The reason for that is that it would tend to hide the improper usage of the class - in other words that the user wasn't calling the correct clean up method. I might use it to put a diagonistic (probably an unchecked exception) which indicates that the resource was not cleaned.
    Expanding further on the other comments made here, if you read the spec you will find that the language does not guarantee that finalize will be called. All that it guarantees is that if it is called it will only be called once. In addition finalize can reduce performance because the existance of it might (and probably will) force the garbage collector to do two passes on the object rather than just one.

  • Garbage Collector periodic rate

    Hello!
    In an application which I'm studying, garbage collector (opportunely configured with command line options) run on a configurable periodic time: this means that every (10 minutes for example) I call method System.gc() in my code.
    If I don't explicitily call this method, Java virtual machine will intervene by itself?
    Will it intervene only when a threshold amonut of memory is consumed (too many JAVA object instantiated which wait for be freed) ?
    Thank you very much in advance
    Diego

    Does anyone knows what's the difference with Full GC
    and why it intervenes ? Because you told it to. You called System.gc().
    I don't think that was the question you meant. My guess is you wanted to know why the Concurrent Low Pause Garbage Collector intervened?
    Off that first link I gave you was an link to an article that describes the GC output log ( http://java.sun.com/docs/hotspot/gc1.4.2/example.html ). If you read that article it describes what each of the values in the gc output means.
    From that article:
    [GC [<collector>: <starting occupancy1> -> <ending occupancy1>, <pause time1> secs] <starting occupancy3> -> <ending occupancy3>, <pause time3> secs]
    where
    <collector> is an internal name for the collector used in the minor collection
    <starting occupancy1> is the occupancy of the young generation before the collection
    <ending occupancy1> is the occupancy of the young generation after the collection
    <pause time1> is the pause time in seconds for the minor collection.
    <starting occupancy3> is the occupancy of the entire heap before the collection
    <ending occupancy3> is the occupancy of the entire heap after the collection
    <pause time3> is the pause time for the entire garbage collection. This would include the time for a major collection is one was done.
    The reason the Concurrent Mark Sweep(CMS) starts is also in the first link I gave you. When the Concurrent Garbage Collector thinks you are about to run out of heap it starts the CMS.
    1234.306: [GC [1 CMS-initial-mark: 342810K(499712K)] 342906K(524224K), 0.0026879 secs]In your case that was when the used heap reached 342810K out of a current allocated heap of 499712K
    You could describe the specific problem you are investigating. Also it would be helpful if you provided the VM parameters you have for starting your application.

  • Garbage Collector and verbose GC

    Hi, we are getting strange behavior with the garbage collector if the verbosegc is enabled. The gc still report it is collecting memory but none is ever freed. If the option is not enabled the problem disapear. Has anyone experience something similar?
    We are running on Sun 5.8 with weblogic 5.1 sp 8 and jdk 1.2.2_09

    Can you post some of the verbosegc output? Output with -XX:+PrintGCDetails might
    help a little more.

  • Garbage Collector Agent

    Hello, I want to know if the Garbage Collector deletes UnFoldered Document. I have created a custom relationship (ThumbnailRelationship) to attache a thumbnail file (a jpeg) to documents. Now, when some one delete a Document, do I have to create a Override to manually delete the ThumbnailRelationship and the Thumbnail document or the Garbage Collector will take care of it ? Where can I get more info on all those Agents running in the background ?
    Thank you
    null

    Hi -
    No, the GarbageCollectionAgent does not delete unfoldered objects. It cleans up references to objects that have been deleted. For example, say a user names testuser1 owns several documents. Then this user gets deleted - who owns the documents? Or more specifcally, what is the value stored in the owner column in the database table? The GarbageCollectionAgent firsts nulls these attributes, and for some attributes (PublicObject.Owner being one of them) it resets the existing objects to reference some other object.
    So, if you want the rightobject of a custom relationship to be automatically deleted when the leftobject is deleted, you'll have to do that via an override on your custom relationship subclass.
    I think the new admin guide has some more detailed information about the out-of-the-box agents.
    hope this helps-
    dave

Maybe you are looking for

  • Organizing iPhoto '09 photos by year

    Hello, Can I get iPhoto 09 to group all my photos (about 10,000) by year, so that I end up with pics by year? I see that I can create a Smart Album to populate with pics taken on a specific day, but I don't see how to get it to do a full specific cal

  • Adapter monitoring and Alerts

    Hi, I have configured a sender e-mail adapter. The adapter is polling the inbox of an e-mail account. Is it possible to monitor this action with alerts? E.g. the email account is locked. So the adapter in the adapter monitoring is red and shows an er

  • Trying to change security preferences so i can use Copy and paste

    I am trying to follow the directions in https://developer.mozilla.org/en-US/docs/Midas/Security_preferences so i can add copy and paste to a certain website. when i try to open the "user.js" file i get an error that i took a screenshot of and can be

  • All .m4v files only import for 1 second (PRE 9/Windows 7)

    Hi, I'm a new PRE 9 user and am experiencing a really significant problem with importing .m4v files: Every .m4v I select ends at the 1-second mark and there does not seem to be any way to make the program see past that 1-second mark in the source fil

  • String "iso-8859-1" to "we8iso8859p1"

    I have this problem: i need to convert mime content-type charset string to oracle charset string. ie. "iso-8859-1" to "we8iso8859p1" or "windows-1250" to "ee8mswin1250". Does exist some function for this?