You state this:
i properly dispose everything.
and this:
I've disposed sqlcommand object by calling oSqlCommand.Dispose()
However, those are mutually exclusive! If you call .Dispose()
directly, you're doing it wrong. Specifically, you're leaving open the possibility that an exception will make the program skip over your call to the Dispose() method. The "proper" way to dispose of your command is to create it with a using block, like so:
using (SqlCommand cmd = new SqlCommand("sql string here"))
{
// use the command here
} // compiler transforms your code to make sure .Dispose() is called here
Now, I gather from your question that this isn't your main problem at the moment, but it is a point worth driving home.
As for you question about the parameters: SqlParameters do not implement IDisposable. Therefore, you do not dispose them directly. They are an entirely managed resource, and that means they will be cleaned up for you by the garbage collector at some point after they are no longer reachable. You don't have to do anything to clean them up.
If you can seriously show that SqlParameter objects are hanging around long after they should, that means that you are holding a reference to them somewhere. For example, perhaps you are "caching" old SqlCommand objects somewhere, which in turn hold on to all their parameters. Don't do that. Find and eliminate whatever still references your SqlParameters, and the garbage collector will clean them up for you.
Update:
After re-reading your question, it sounds like your xml parameters are ending up on the Large Object Heap. The garbage collector in .Net is generational - it doesn't clean up everything every time it runs. As an object moves to a higher generation, it's more likely to hang around a while. The Large Object Heap is basically the last generation, and it does not get cleaned up much at all. More than that, it does not get compacted ever, such that over time it fragments, resulting in your program holding on to much more data than it needs. What you need to do is try to find a way to keep from loading the entire xml data for a parameter into memory, such that it never makes it to the large object heap. Use a file stream, or something similar instead.