I have a wcf service hosted as a windows service with the following function:
public int SendMultipleMessages(List<Message> messages)
{
foreach (var message in messages)
{
//Do some stuff with the messages ie. get an id to return, save info in a db.
}
//Would it make sence to collect here ??
Gc.Collect();
Task.Factory.StartNew(() =>
{
//very time demanding task
_sendRequestHandler.SendMultipleMessages(BatchId);
});
return BatchId;
}
The List< Message > object (more often than not) uses up to 1 gb of memory, would it make sense to call GC.Collect in a situation like this, since im not using the list anymore, or should i let the Garbage collector handle this on its own ?