By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,247 Members | 1,517 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,247 IT Pros & Developers. It's quick & easy.

Windows service memory management

P: n/a
I've written a windows service (VB.NET 2003). When running, it consumes between 20-40 MB memory.

How do I optimize the memory usage?

I've set all objects to Nothing when I'm done using them.

What else can i do?

Regards,
Mikael
Jul 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Mikael,

Unless your memory usage keeps growing uncontrollably (i.e. after a few days
of having your service running it gets larger and larger), I wouldn't worry
about it.

..NET has a pretty complex memory management engine. On systems with a lot of
free memory, it may allocate more than it needs to keep performace up. Also,
when a .NET application is loaded, a lot of memory has to be allocated for
hosting the CLR. Even though task manager says it's using 40mb, not all of
this may be allocated, and some may still be available to other applicatons
to use if the system runs low on memory. Don't judge your total memory usage
on this figure.

Unless you're a pretty advanced user and want to get your hands dirty with
the operating system memory management features, don't worry about it.
I've set all objects to Nothing when I'm done using them.
Setting references to nothing does not de-allocate the memory used by
objects. They stay in the background until the Garbage collector comes along
and finalizes them. If you are using objects that implement the IDisposable
interface or have a "dispose" or "close" method on them, make sure you call
that before setting the object to nothing - this will ensure any unmanaged
resources (such as database connections or files) will be closed properly.

HTH,

Trev.
"Mikael Sorensen" <an*******@discussions.microsoft.com> wrote in message
news:4E**********************************@microsof t.com... I've written a windows service (VB.NET 2003). When running, it consumes between 20-40 MB memory.
How do I optimize the memory usage?

I've set all objects to Nothing when I'm done using them.

What else can i do?

Regards,
Mikael

Jul 21 '05 #2

P: n/a
Thanks Tre

I will monitor the service for about a week and see what happends

Regards
Mikael
Jul 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.