look at this code carefullyyyy .....
void test(Connection l_con)
{
Statement l_stmt = l_con.createStatement();
l_stmt.close(); //Sholud i do this to avoid maximum cursors open error
}
i mean when the method calling finished then the local reference l_stmt will be destroyed then will JVM close all resources associated with it ....
plz explain me in details ....
thanx
14 1374
look at this code carefullyyyy .....
i mean when the method calling finished then the local reference l_stmt will be destroyed then will JVM close all resources associated with it ....
plz explain me in details ....
thanx
Yes you should close it yourself. The JVM may close it before garbage collecting but that depends on the platform.
oh really .... is this true .....
could u say me one more thing does the JVM provided by SUN has this facility ...
plz say ....
thanxxxxx
oh really .... is this true .....
could u say me one more thing does the JVM provided by SUN has this facility ...
plz say ....
thanxxxxx
Garbage collection like Concurrency is one of those things in Java that are not platform independant. You cannot say when a useless variable's contents are removed from memory. Even is you call System.gc(), garbage collection may not occur. It depends on the memory algorithms of the OS you are using. So leaving a connection open and hoping it will get closed on cleanup is not safe because you never know when clean up actually takes place.
thanx for ur detail info ... thanxxxxx
oh sorry i forget to mention ....
i don't understand the secind line ...
plz explain me in details ...........
oh sorry i forget to mention ....
i don't understand the secind line ...
plz explain me in details ...........
which line, dj?
sorry i misspell ......
the second line....
plz say .... thanx
sorry i misspell ......
the second line....
plz say .... thanx
Assuming you mean this:"You cannot say when a useless variable's contents are removed from memory."
A variable holds the address of where an object is stored in memory.
If you have -
-
Double x = new Double(3); //memory for Double(3) object
-
Double y = new Double(5); //memory for Double(5) object
-
Then after
The variable x is no longer refering to the object Double(3), but is now refering to the Double(5) object. The Double(3) object is no longer being referenced and there is no longer any way of accessing it now. We say that it is ligible for garbage collection. However, you cannot say whether it has been removed from memory yet. It is the duty of the garbage collector to remove that Double(3) object from memory and we don't know when exaclt the GC is going to remove that object from memory even though it is now useless.
ok now i can understand ur words ....
many many thanxxxx
Assuming you mean this:"You cannot say when a useless variable's contents are removed from memory."
A variable holds the address of where an object is stored in memory.
If you have -
-
Double x = new Double(3); //memory for Double(3) object
-
Double y = new Double(5); //memory for Double(5) object
-
Then after
The variable x is no longer refering to the object Double(3), but is now refering to the Double(5) object. The Double(3) object is no longer being referenced and there is no longer any way of accessing it now. We say that it is ligible for garbage collection. However, you cannot say whether it has been removed from memory yet. It is the duty of the garbage collector to remove that Double(3) object from memory and we don't know when exaclt the GC is going to remove that object from memory even though it is now useless.
I hear you r0.
But Remember there are also primitive values to take care of. The Statement "A variable holds the address of where an object is stored in memory" May not necessarily hold coz primitives are not objects .... a java trade off from object orientation, for practicality........ A primitive variable actually holds the bit pattern of the value it represents. My question is :Does that mean primitives are never garbage collected
yes why not .... i think u didn't get ros' point of view ........
he answered my question perspective ..... the primitive datas are garbage collected
yes why not .... i think u didn't get ros' point of view ........
he answered my question perspective ..... the primitive datas are garbage collected
Anything that has memory reserved for it can be garbage collected. So I should have included the primitive types there. Of course the primitives are stored in a different manner than objects are. Primitives are stored in constant size memory. I should probably have also included the special way that Strings are handled but I thought that might have clouded the issue at hand.
Anything that has memory reserved for it can be garbage collected. So I should have included the primitive types there. Of course the primitives are stored in a different manner than objects are. Primitives are stored in constant size memory. I should probably have also included the special way that Strings are handled but I thought that might have clouded the issue at hand.
I am new to this forumn, but so far I am impressed. Thanks. It's nice to be around "Real" java developers...I didn't mean to cloud the thread. Just an open mind taht scrutinises.
I hear u on the String object storage and immutability. I will let you post it on one of those tutorial postings that you so much keep updated.
Keep it up. I'm impressed
actually here the point u can understand clearly that how garbage collection depends on the meory issue of the OS .....
thanx N002199B u made me more clear ........
thanxxxxxx aallottt of thanxxxx
Sign in to post your reply or Sign up for a free account.
Similar topics
by: mike420 |
last post by:
In the context of LATEX, some Pythonista asked what the big
successes of Lisp were. I think there were at least three *big*
successes.
a. orbitz.com web site uses Lisp for algorithms, etc.
b....
|
by: Greg Merideth |
last post by:
I was looking for a way to pass, by reference, a class to a webmethod to allow
the web method to alter the values of some (now) 50 variables of the class.
Now, to get this to work, I have to put...
|
by: matko |
last post by:
Hi!
In one of the two examples for the PaintEventArgs.Graphics-property (in
the VS 2005 documentation), the Graphics-object is "saved" to a local
variable, before being used. In the other...
|
by: eman1000 |
last post by:
I was recently looking at the prototype library
(http://prototype.conio.net/) and I noticed the author used the
following syntax:
Object.extend(MyObj.prototype, {
my_meth1: function(){},...
|
by: Jeff |
last post by:
Hello,
I assigned a new object to a local variable ("req") in a function (see
below). The local variable "req" is obviously destroyed when the
function exits, but should the object referenced by...
|
by: =?Utf-8?B?RE9UTkVUR1VZ?= |
last post by:
Hello,
In vb.net there is a with statement, Is there are similar constructor in c#?
|
by: Hendri Adriaens |
last post by:
Hi,
I'm trying to automate the creation of an excel file via COM. I copied my
code below. I read many articles about how to release the COM objects that I
create. The code below runs just fine...
|
by: digz |
last post by:
This is a very simplified version of something I am trying to
understand.
The State object holds the strings and maps , and I pass a reference
to State to the process Function which manipulates it...
|
by: Tony Johansson |
last post by:
Hello!
I just wonder what is the point of having the reader variable declared as
TextReader in the snippet below..
Is it because of using the polymorfism on the reader variable perhaps.
using...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |