Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

Memory cleaning

I'm trying to set up an instance where a program will periodically work with command objects that are stored in a simple collection class. The program that I'm writing uses some command objects all the time and I think that it will make the program faster if I just stored the configured command object in a collection instead of having to recreate and configure the same object again and again.

However, to prevent what could be a massive memory leak from occurring, I'm trying to set up a system whereby the program will periodically clean out the collection class so that any command object not used within a fixed period of time will be discarded.

To set this up, I figured that I would spawn a separate thread when the web application launches. But, I'm not sure if it is even wise (let alone doable) to have one thread within a program play around with the memory in another thread?

Any advice from this group is gratefully appreciated.

Laurence -
[1013 byte] By [Hunterlmc] at [2007-11-11 10:30:40]