Application Recycling

  • Thread starter Thread starter Marios
  • Start date Start date
M

Marios

Hi,
I want to have in a application i have created the feature of application
recycling,
similar to the aspnet_wp, and the new COM+ service.
The reason i want to do this is because of being able to set limits to the
memory usage my app
can consume, and recycling it when it exceeds this limit.
What I have done so far, is to create an application domain, in which all
the objects i use are created,
and by defining a certain number of method calls, or a memory threshold, i
unload this domain and load
it again rigtht after.
However, because i use a number of threads in the app, i have to write code
that unloads the application domain,
only when all the created threads have finished their work, and pausing of
course the creation of new ones.
The threads i use, come from a timer
Until no i have some satisfactory results, but i would like to here some
more ideas, if any one has the time

Thanks
 
Marios,

Unloading an application domain won't do anything for you in this case I
believe. The GC and the managed heap extends across all application domains
in the process. So even if you shut down one application domain, you won't
reclaim the memory that you think is leaking (which it probably isn't).
 
Nicholas
thank u for your answer.
However i have noticed that whenever i unload the custom domain i create,
the memory the application consumes is reduced.
Anyway, if that does not work 100% satisfactory, i am thinking of creating
custom processes and terminating these.
Do u have any other suggestion ?

Nicholas Paldino said:
Marios,

Unloading an application domain won't do anything for you in this case I
believe. The GC and the managed heap extends across all application domains
in the process. So even if you shut down one application domain, you won't
reclaim the memory that you think is leaking (which it probably isn't).

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Marios said:
Hi,
I want to have in a application i have created the feature of application
recycling,
similar to the aspnet_wp, and the new COM+ service.
The reason i want to do this is because of being able to set limits to the
memory usage my app
can consume, and recycling it when it exceeds this limit.
What I have done so far, is to create an application domain, in which all
the objects i use are created,
and by defining a certain number of method calls, or a memory threshold, i
unload this domain and load
it again rigtht after.
However, because i use a number of threads in the app, i have to write code
that unloads the application domain,
only when all the created threads have finished their work, and pausing of
course the creation of new ones.
The threads i use, come from a timer
Until no i have some satisfactory results, but i would like to here some
more ideas, if any one has the time

Thanks
 
Marios,

I still don't understand why you are doing it. I would be less worried
about the memory consumption on the machine and more concerned about whether
or not the application is performing correctly and in a performant manner
(the memory consumed does not indicate that it is NOT performant).

What you are seeing is natural for a GC system.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Marios said:
Nicholas
thank u for your answer.
However i have noticed that whenever i unload the custom domain i create,
the memory the application consumes is reduced.
Anyway, if that does not work 100% satisfactory, i am thinking of creating
custom processes and terminating these.
Do u have any other suggestion ?

in message news:[email protected]...
Marios,

Unloading an application domain won't do anything for you in this
case
I
believe. The GC and the managed heap extends across all application domains
in the process. So even if you shut down one application domain, you won't
reclaim the memory that you think is leaking (which it probably isn't).

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Marios said:
Hi,
I want to have in a application i have created the feature of application
recycling,
similar to the aspnet_wp, and the new COM+ service.
The reason i want to do this is because of being able to set limits to the
memory usage my app
can consume, and recycling it when it exceeds this limit.
What I have done so far, is to create an application domain, in which all
the objects i use are created,
and by defining a certain number of method calls, or a memory
threshold,
pausing
 
Nicholas,
the reason i want to do this is simple.
I have created a windows service with a timer , and another one with a
simple file system event watcher.
Although i properly dispose all the objects that i use, i have even
commented the code running inside the event,
at every event execution an additional amount of memory is kept, and the
thing is that the memory allocation
is never reduced. That had a simple effect. It has finally allocated a very
large number of megabytes in RAM, in
a production server that made the service simply not acceptable by the
client.
That is why i want to be able to do this, so that it will not happen again.


Nicholas Paldino said:
Marios,

I still don't understand why you are doing it. I would be less worried
about the memory consumption on the machine and more concerned about whether
or not the application is performing correctly and in a performant manner
(the memory consumed does not indicate that it is NOT performant).

What you are seeing is natural for a GC system.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Marios said:
Nicholas
thank u for your answer.
However i have noticed that whenever i unload the custom domain i create,
the memory the application consumes is reduced.
Anyway, if that does not work 100% satisfactory, i am thinking of creating
custom processes and terminating these.
Do u have any other suggestion ?

in message news:[email protected]...
Marios,

Unloading an application domain won't do anything for you in this
case
I
believe. The GC and the managed heap extends across all application domains
in the process. So even if you shut down one application domain, you won't
reclaim the memory that you think is leaking (which it probably isn't).

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Hi,
I want to have in a application i have created the feature of application
recycling,
similar to the aspnet_wp, and the new COM+ service.
The reason i want to do this is because of being able to set limits
to
the
memory usage my app
can consume, and recycling it when it exceeds this limit.
What I have done so far, is to create an application domain, in
which
all
the objects i use are created,
and by defining a certain number of method calls, or a memory
threshold,
i
unload this domain and load
it again rigtht after.
However, because i use a number of threads in the app, i have to write
code
that unloads the application domain,
only when all the created threads have finished their work, and
pausing
of
course the creation of new ones.
The threads i use, come from a timer
Until no i have some satisfactory results, but i would like to here some
more ideas, if any one has the time

Thanks
 
Marios,

That's the thing, this is SUPPOSED to happen. The CLR is going to try
and consume resources until it deems that it should give them back. It is
the CLR's business to manage this. This is why they call it "managed
memory".


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Marios said:
Nicholas,
the reason i want to do this is simple.
I have created a windows service with a timer , and another one with a
simple file system event watcher.
Although i properly dispose all the objects that i use, i have even
commented the code running inside the event,
at every event execution an additional amount of memory is kept, and the
thing is that the memory allocation
is never reduced. That had a simple effect. It has finally allocated a very
large number of megabytes in RAM, in
a production server that made the service simply not acceptable by the
client.
That is why i want to be able to do this, so that it will not happen again.


in message news:[email protected]...
Marios,

I still don't understand why you are doing it. I would be less worried
about the memory consumption on the machine and more concerned about whether
or not the application is performing correctly and in a performant manner
(the memory consumed does not indicate that it is NOT performant).

What you are seeing is natural for a GC system.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Marios said:
Nicholas
thank u for your answer.
However i have noticed that whenever i unload the custom domain i create,
the memory the application consumes is reduced.
Anyway, if that does not work 100% satisfactory, i am thinking of creating
custom processes and terminating these.
Do u have any other suggestion ?

in message Marios,

Unloading an application domain won't do anything for you in
this
case
I
believe. The GC and the managed heap extends across all application
domains
in the process. So even if you shut down one application domain, you
won't
reclaim the memory that you think is leaking (which it probably isn't).

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Hi,
I want to have in a application i have created the feature of
application
recycling,
similar to the aspnet_wp, and the new COM+ service.
The reason i want to do this is because of being able to set
limits
to here
some
 
Nicholas,

The GC does a full garbage collection when it unloads an appdomain, so the
resources used in an appdomain should be reclaimed when it is unloaded.
There currently is a small memory leak (about 12 bytes) per unloaded
appdomain.

Dave
PS: Full disclosure - info based on Chris Brumme's most excellent blog.


Nicholas Paldino said:
Marios,

Unloading an application domain won't do anything for you in this case I
believe. The GC and the managed heap extends across all application domains
in the process. So even if you shut down one application domain, you won't
reclaim the memory that you think is leaking (which it probably isn't).

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Marios said:
Hi,
I want to have in a application i have created the feature of application
recycling,
similar to the aspnet_wp, and the new COM+ service.
The reason i want to do this is because of being able to set limits to the
memory usage my app
can consume, and recycling it when it exceeds this limit.
What I have done so far, is to create an application domain, in which all
the objects i use are created,
and by defining a certain number of method calls, or a memory threshold, i
unload this domain and load
it again rigtht after.
However, because i use a number of threads in the app, i have to write code
that unloads the application domain,
only when all the created threads have finished their work, and pausing of
course the creation of new ones.
The threads i use, come from a timer
Until no i have some satisfactory results, but i would like to here some
more ideas, if any one has the time

Thanks
 
Back
Top