Background: I have a 2 class A & B. Class A contains 1 int64, 1 int, 1 datetime, 6 strings, 1 byte[] and a list of Class B objects.
Class B contains 2 Int64, 1 enum (4values), 5 strings.
Class A and B have a master detail relationship between them. Class A can have 0 or more objects of Class B in its list.
These objects are used to store search results from our db.
We have a SOA architecture. The client can search withing a particular date range and with a fixed set of criteria. We use these on the service to gather the search results and push them to the client in batches. After sending each batch, we delete those objects from the service.
Problem: If a user does a search that returns 200k results (Class A + Class B counts combined), the service memory consumption jumps 200mb. But if subsequent searches return only few results, the memory doesn't come back to its previous state. When I look at the performance counters for the service, I see that lot of memory is taken up by gen2 objects.
Without trying to do a GC.Collect(), how can I make sure that that memory is returned more quickly? I though of using the IDisposable interface on Class A and Class B, but since most of the fields in both of them are strings, I don't know how I can forcefully dispose them.