Object ?

  • Thread starter Thread starter WJ
  • Start date Start date
W

WJ

I have a Database class that is responsible for performing DBIO to/from
Oracle RDBMS named "oraDBIOClass". It is c#. I have about 20 Asp.Net forms
(*.aspx) in my web site, their Url Links are located on a common launch pad
(graphic with hot spots), each calls different methods within the
oraDBIOClass.

Questions:

1. When an instance of "oraDBIOClass" is created, where is it placed in term
of memory (on the Heap, by the side or at the bottom of the heap or in the
heart of Intel CPU chip ?)

2. Each time a request is launched, an oraDBIOClass instance is created.

Example:
Webform1.aspx creates "oraDBIOClass ora1=new
oraDBIOClass() when it is clicked...
Webform2.aspx creates "oraDBIOClass ora2=new
oraDBIOClass() ...
Webform3.aspx creates "oraDBIOClass ora3=new
oraDBIOClass() ...

Then how does the system know that "ora1" instance is to be disposed of (how
does it know ?). I still think that "ora1" is still there with WebForm1.aspx
on the server ?

My understanding is this: My application does not know or cannot control
when the user clicks on a new link, therefore, it cannot free the current
instance named "ora1, 2 and or 3" ? Or I should not worry about it and let
the CLR takes care of it at runtime ?

Reason I ask because I need to worry about 100 concurrent accesses with
forms being clicked all over the place and soon the memory (4GB) runs out...

Thanks for your help,

John
 
Hi,
The runtime probably uses reference counting to determine what objects can
be garbage collected. When an object cannot be traversed to via any object
graph it is elligible for garbage collection, and the runtime may dispose it
the next time gc runs.
 
1. When an instance of "oraDBIOClass" is created, where is it placed in
term
of memory (on the Heap, by the side or at the bottom of the heap or in the
heart of Intel CPU chip ?)

On the stack.
2. Each time a request is launched, an oraDBIOClass instance is created.

Example:
Webform1.aspx creates "oraDBIOClass ora1=new
oraDBIOClass() when it is clicked...
Webform2.aspx creates "oraDBIOClass ora2=new
oraDBIOClass() ...
Webform3.aspx creates "oraDBIOClass ora3=new
oraDBIOClass() ...

Then how does the system know that "ora1" instance is to be disposed of (how
does it know ?). I still think that "ora1" is still there with WebForm1.aspx
on the server ?

A WebForm class and its dependencies and dependents generally exist for a
matter of milliseconds, the amount of time between the receipt of an HTTP
Request for a Page, and the time the Response is sent. The client-side HTML
document exists, therefore, at a different time than the server-side
classes. Garbage Collection takes care of cleaning up the classes when the
Page goes out of scope (finishes processing).

A class instance is not a class, in a sense. It is a copy, or "instance" of
that class. When you create 3 instances of the same class, you are creating
3 separate objects, which do not have anything to do with one another.
My understanding is this: My application does not know or cannot control
when the user clicks on a new link, therefore, it cannot free the current
instance named "ora1, 2 and or 3" ? Or I should not worry about it and let
the CLR takes care of it at runtime ?
Reason I ask because I need to worry about 100 concurrent accesses with
forms being clicked all over the place and soon the memory (4GB) runs
out...

It may be that your database class isn't closing its' Connections. Due to
the connected nature of a Connection, once established, it has 2
dependencies, one at each "end" of the Connection. If you don't close it, it
isn't released back into the Connection Pool, and even after the Page is
long gone, the Connection can be "orphaned" in memory. Make sure you
explictly close every Connection you open, ASAP.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
I get paid good money to
solve puzzles for a living
 
Back
Top