answersLogoWhite

0

Garbage collection in net and j2ee?

Updated: 12/17/2022
User Avatar

Wiki User

12y ago

Best Answer

How Does the Garbage Collector Work?

You just can't be sure. You might hear that the garbage collector uses a mark and sweep algorithm, and for any given Java implementation that might be true, but the Java specification doesn't guarantee any particular implementation. You might hear that the garbage collector uses reference counting; once again maybe yes maybe no. The important concept to understand for the exam is when does an object become eligible for garbage collection? To answer this question fully, we have to jump ahead a little bit and talk about threads. (Don't worry, We will take a detailed look at Threads in future.) In a nutshell, every Java program has from one to many threads. Each thread has its own little execution stack. Normally, the programmer causes at least one thread to run in a Java program, the one with the main() method at the bottom of the stack. However, there are many really cool reasons to launch additional threads from your initial thread. In addition to having its own little execution stack, each thread has its own lifecycle. For now, all we need to know is that threads can be alive or dead. With this background information, we can now say with stunning clarity and resolve that an object is eligible for garbage collection when no live thread can access it.

Based on that definition, the garbage collector does some magical, unknown operations, and when it discovers an object that can't be reached by any live thread, it will consider that object as eligible for deletion, and it might even delete it at some point. When we talk about reaching an object, we're really talking about having a reachable reference variable that refers to the object in question. If our Java program has a reference variable that refers to an object, and that reference variable is available to a live thread, then that object is considered reachable. We'll talk more about how objects can become unreachable in the following section.

Can a Java application run out of memory? Yes. The garbage collection system attempts to remove objects from memory when they are not used. However, if you maintain too many live objects (objects referenced from other live objects), the system can run out of memory. Garbage collection cannot ensure that there is enough memory, only that the memory that is available will be managed as efficiently as possible.

User Avatar

Wiki User

12y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Garbage collection in net and j2ee?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

2 What is the purpose of garbage collection in java and when is it used?

Garbage collection prevents memory leaks. In Java, the Java Virtual Machine will garbage collect whenever there is memory that has no references.


What are the Rules and regulations in collection and disposal of garbage?

recycling


What is J2EE appilication server?

The J2EE application server is the server in which the j2ee application would run. Without the server a j2ee application cannot run. Some famous j2ee application servers are: a. Websphere b. Weblogic c. Tomcat d. etc


How is garbage collection done in c plus plus?

Garbage collection is used to released resources which were previously used by the application(s) which is called garbage collector. Garbage collection allows to prevent memory leaks which are the main problem of old style of programming.


Is the CLR manages the execution of code and provides services to simplify the development process?

The CLR, or Common Language Runtime, is part of the compilation process of .NET (including C# and VB.NET) applications. It runs on top of your .NET application to take care of the managed features of those languages, such as garbage collection, memory management, and exception handling. As far as simplifying the development process, it does in respect to not having to deal with garbage collection, memory management, etc. as you do in some other languages like C or C++ Other than that however, it does not directly simplify the development process in terms of providing you built in methods and objects. For that, you probably are referring to the .NET Framework.

Related questions

How many generations does the garbage collection algorithm in NET support?

2


What is the difference between j2ee and dot net because both support web application development?

Plateform independency in J2ee whereas in .net(Microsoft) needs plateform supporting MS.


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


What is the need for garbage collection?

Assuming you mean garbage collection in computers: it is a method often used to reclaim memory, once it is no longer used. Note that garbage collection is not the only possible way to manage memory.


Who performs the garbage collection?

A garbage truck. In computer programming, a process known as the garbage collector.


Garbage collection in the Middle Ages was often done by .?

Garbage collection in the Middle Ages was often done by roaming animals.


Who are famous people who have a garbage collection?

Everyone in the world has a garbage collection and really does not matter if you are famous or not. To not have your garbage collected would be consider unsanitary to some and hoarding to others.


How you can inforce the garbage collection?

Forcing Garbage CollectionFirst and foremost, unlike this paragraphs title, 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).


2 What is the purpose of garbage collection in java and when is it used?

Garbage collection prevents memory leaks. In Java, the Java Virtual Machine will garbage collect whenever there is memory that has no references.


What does J2EE stand for?

J2EE is an acronym for the Java 2 Platform Enterprise Edition (J2EE).


Abbreviation of j2ee?

The full form of J2EE is Java 2 Platform, Enterprise Edition (J2EE),


What are the Rules and regulations in collection and disposal of garbage?

recycling