Search the archives!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Garbage Collector question?
- From: yogesh@xxxxxxxxx (Yogesh Pandeya)
- Subject: Garbage Collector question?
- Date: Tue, 30 Nov 1999 19:14:51 -0000
Hi Shrihari, When you start a VM, it gets some initial memory from the system. It = differs from VM to VM and version to version. That is the default size = of the VM's memory. You can change the initial memory using -Xms option = while starting the VM. Now whenever you do a "new", it is a *potential* trigger for gc, but not = always neccessary. when the VM starts running out of memory because of = object creation, it tries to first collect some garbage and allocate = memory to objects. If it still requires more memory, it gets it from the = system(underlying OS) and runs with higher memory. this newly acquired = memory is not returned back to the system till VM runs. You can check = this by using runtime total memory and free memory. You will find the = total memory increasing as you create more objects without assigning it = to null.=20 The idea behind object pool is that if you know that you are going to = create large number of objects again and again for some processing, you = create a pool (or bucket) of objects at the time of initialization. = during run time you take the objects from the bucket, use them for your = purpose, and return them to the bucket. For this you have a pool manager = which is initialized in the begining and you request the manager to = create objects (you will need down the line during run time) during = initialization. During run time you request those objects from the = manager, initialize them as needed, and return them to the manager after = use. This saves a lot of you time for object creation. The objects = created in the pool are not temporary. They satay with you for the = application lifetime unless you have methods in the manager to = specifically destroy them.(setting them to null) Hope this helps you to understand things. Cheers, Yogesh -----Original Message----- From: Shrihari.S.C [SMTP:sriharis@xxxxxxxxxxxxxxxxxxxx] Sent: Tuesday, November 30, 1999 4:06 PM Cc: Java Mail List Subject: RE: Garbage Collector question? Hi Yogesh, Could u be more clear on how JVM gets more memory if the gc does n't = get u space. Can temporary objects in the object pool be reused and if so how to do = that? Regards Shrihari > -----Original Message----- > From: Yogesh Pandeya [mailto:yogesh@xxxxxxxxx] > Sent: Tuesday, November 30, 1999 9:15 PM > To: 'Shrihari.S.C'; Java Mail List > Subject: RE: Garbage Collector question? > > > Hi Srihari, > Its not always the case that gc runs as a low priority thread. > When the JVM runs short of memory, gc runs at high priority to > reclaim space. If it could not get space by gc, it(JVM) gets more > memory from the system.(correct me Gurus if I am wrong) > > About temperory objects.... > If you are declaring an object handle locally, and assigning new > object to it, it will be gabage collected if it goes out of > scope. If you are declaring the handle at the top level, and > allocate a new object to it, it will hang around with you unless > you assign it to null. This kind of memory leaks are programer's > creation and he/she has to take care of it. > If you need to create many objects locally many times, its always > a good idea to use object pool as it will improve the performance > significantly as "new" is a costly affair. > Does this make sense or I am missing somthing??? > regards, > Yogesh > > > -----Original Message----- > From: Shrihari.S.C [SMTP:sriharis@xxxxxxxxxxxxxxxxxxxx] > Sent: Tuesday, November 30, 1999 2:41 PM > To: Java Mail List > Cc: yogesh@xxxxxxxxx > Subject: RE: Garbage Collector question? > > Hi Yogesh, > The System.gc() is a low priority thread that cleans those > set of objects > that are not from the primordial class loader , but from the custom = class > loader and those which has been assigned null. But considering > the fact that > the class contains too many objects that have been temporarily created > because of some intermediate computation and have not been assigned = null, > before which the computation is exited, the System.gc() siezes to work > because of improper set of unreferenced objects to be > deallocated. What do u > think can be set of other options left out to see this problem ? > Regards > Shrihari > > -----Original Message----- > > From: Yogesh Pandeya [mailto:yogesh@xxxxxxxxx] > > Sent: Tuesday, November 30, 1999 7:32 PM > > To: 'magesh@xxxxxxxxxxxxxxxx'; punam > > chordia > > Subject: RE: Garbage Collector question? > > > > > > > > Hi Magesh, > > Another sequence on gc!!!! Anyway..... > > > > Putting System.gc() doesn't guarantee that it will run when you > > want to. Its VM's prerogative to run gc or not. It is guaranteed > > run at the point you put System.gc(), only if you run the > > application with -noclassgc (or -Xnoclassgc) option. > > Other point to note is, if you are creating objects temporarily, > > you can use an object pool and reuse your objects. There is good > > article this month's Javaworld. > > Hope it helps, > > cheers, > > Yogesh > > > > -----Original Message----- > > From: magesh@xxxxxxxxxxxxxxxx [SMTP:magesh@xxxxxxxxxxxxxxxx] > > Sent: Tuesday, November 30, 1999 1:23 PM > > To: advanced-java@xxxxxxxxxxxxxxxx; punam chordia > > Subject: RE: Garbage Collector question? > > > > > > > > Hi, > > > > Does this guarantee that the System.gc() will run without > getting context > > switched > > because it has a low priority?? > > > > thanks, > > mmp. > > > > > > > > > > > > punam chordia <punamac@xxxxxxx> on 11/30/99 02:44:03 AM > > > > To: Mageshkumar Maruthapillai/Technology Providers/lk > > cc: > > Subject: RE: Garbage Collector question? > > > > > > > > > > We also had a similar problem. > > U can run garbage collector explicitly by writing the following line = of > > code, > > System.gc(); > > I hope it helps you. > > Punam Chordia > > Software Engineer > > ITL Infosys, Pune. > > Ph. 91-020-647420/1 Extension: 1046 > > > -----Original Message----- > > > From: magesh@xxxxxxxxxxxxxxxx [SMTP:magesh@xxxxxxxxxxxxxxxx] > > > Sent: Tuesday, November 30, 1999 PM 01:06 > > > To: advanced-java@xxxxxxxxxxxxxxxx > > > Subject: Garbage Collector question? > > > > > > > > > > > > Hi, > > > > > > My server code is consuming a lot of memory dur to a large = number > > > of objects being created temporarily. > > > > > > I want to be able to get a reference to the garbage collector > > > of the virtual machine so that I can give it a high priority to it > > > very short intervals intermittently. > > > > > > > > > Is there a way to get the reference to the garbage collector? > > > > > > > > > any help is appreciated. > > > > > > thanks, > > > mmp > > > > > > > > > > > > --- > > > To unsubscribe, mail advanced-java-unsubscribe@xxxxxxxxxxxxxxxx > > > To get help, mail advanced-java-help@xxxxxxxxxxxxxxxx > > > > > > > > > > > > --- > > To unsubscribe, mail advanced-java-unsubscribe@xxxxxxxxxxxxxxxx > > To get help, mail advanced-java-help@xxxxxxxxxxxxxxxx > > > > --- > > To unsubscribe, mail advanced-java-unsubscribe@xxxxxxxxxxxxxxxx > > To get help, mail advanced-java-help@xxxxxxxxxxxxxxxx > > --- To unsubscribe, mail advanced-java-unsubscribe@xxxxxxxxxxxxxxxx To get help, mail advanced-java-help@xxxxxxxxxxxxxxxx --- To unsubscribe, mail advanced-java-unsubscribe@xxxxxxxxxxxxxxxx To get help, mail advanced-java-help@xxxxxxxxxxxxxxxx
- Prev by Date: Virus (netian.com junk mail)
- Next by Date: image query...
- Previous by thread: Garbage Collector question?
- Next by thread: Garbage Collector question?
- Index(es):