answersLogoWhite

0


Best Answer

garbage collection cannot be forced. However, Java provides some methods that allow you to request that the JVM perform garbage collection.

In reality, it is possible only to suggest to the JVM that it perform garbage collection. However, there are no guarantees the JVM will actually remove all of the unused objects from memory (even if garbage collection is run). It is essential that you understand this concept for the exam.

The garbage collection routines that Java provides are members of the Runtime class. The Runtime class is a special class that has a single object (a Singleton) for each main program. The Runtime object provides a mechanism for communicating directly with the virtual machine. To get the Runtime instance, you can use the method Runtime.getRuntime(), which returns the Singleton. Once you have the Singleton you can invoke the garbage collector using the gc() method. Alternatively, you can call the same method on the System class, which has static methods that can do the work of obtaining the Singleton for you. The simplest way to ask for garbage collection (remember-just a request) is

System.gc();

Theoretically, after calling System.gc(), you will have as much free memory as possible. We say theoretically because this routine does not always work that way. First, your JVM may not have implemented this routine; the language specification allows this routine to do nothing at all. Second, another thread might grab lots of memory right after you run the garbage collector.

This is not to say that System.gc() is a useless method-it's much better than nothing. You just can't rely on System.gc() to free up enough memory so that you don't have to worry about running out of memory

User Avatar

Wiki User

13y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Can you force a garbage collecter to run for the specific class?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What type of machine is a paper cutter?

It's a simple machine, more specifically a second class lever. That means there is a specific effort force, fulcrum and object force.


Can a town force you to pay for garbage pick up?

Yes


How do you force garbage collection in java?

. Garbage collection cannot be forced. Calling System.gc() or Runtime.gc() is not 100 percent reliable, since the garbage-collection thread might defer to a thread of higher priority


Class levers have the resistance force between the effort force and the fulcrum?

Class 2.


Identify the class of lever for which the fulcrum is between the input force and the output force?

2nd class


Identify the class of a lever for which does function is between the input force and the output force?

The third class lever functions between the input force and the output force


Which class of lever does not multiply input force?

The first class lever (force, fulcrum, load) doesn't change the force if the lever is symetrical. Note that if it is assymetrical, the force will change.


What kind of lever is a seesaw?

yes it is a 1st class lever and so is a pair of pliers!!!!


How can you force the garbage collector to run?

You can't force it but you call System.gc(), which is a "hint" to the runtime engine that now might be a good time to run the GC. But garbage collection using this method is not guaranteed to be done immediately. there is another way to explicitly call the gc(). this method is also define in Runtime class of package java.lang. But u can not create a direct object of class Runtime like Runtime a = new Runtime(); //wrong For that u have to call the method getRuntime() which is static and it is also define in Runtime class the way to create object is Runtime run; //right run = Runtime.getRuntime(); //right now u can call the gc() through the "run " Object. like run.gc(); //right


Is the lever increase the force to move an object but it does not change the direction of the force?

There are 3 basic types of levers. 1st class, 2nd class and 3rd class. some change the direction of the force, some do not. some increase the force, some do not. A broom is an example of increasing speed, but not force. The direction of the effort (force you put in) and the resistance (force applied to the floor) is the same.


What is cumulative force?

cumultive force is the force that acts upon a specific object


What simple machine is the output force less than the input force?

Some Class-I levers, and all Class-III levers.