Thanks for the test app. I've run it fifty or more times and don't believe there's a memory leak although memory usage is high.
If I keep hitting the endpoint, process memory increases until it plateaus at around 1.5GB. Looking at the heap, there's about 24K objects consuming 133MB. I suspect these numbers will vary depending on how much system memory is available but that's what I see on my machine. By comparison, when the app starts and prior to hitting the endpoint, process memory usage is 68MB and the heap has 20K objects consuming 2MB.
As an experiment, I added another endpoint which simply called GC.Collect().
I tried various combinations of importing the metadata and calling the garbage collector by browsing to the respective endpoints. For example, sometimes I called the garbage collector after each import. Other times I did ten or twenty imports and then ran the garbage collector a few times. In all cases, after garbage collection completed the process memory usage dropped to 640MB and the heap had 24K objects consuming 2MB.
I'm not suggesting you call the garbage collection in a production application. I merely did this as an experiment.
I suggest doing something similar to confirm the results I saw.
Also, looking at the heap, there are just a couple ComponentSpace objects consuming a few dozen bytes. This makes sense as we're not keeping references to any of the objects associated with the metadata import.
Given the large size of the metadata document being downloaded and imported, this generates a large number of objects and consumes significant memory. However, the .NET garbage collector will eventually clean things up.
As I mentioned earlier, I suggest employing some of the techniques used by the CheckForMetadataUpdates project to minimize the number of downloads.
Let me know if you still have any concerns.
Regards ComponentSpace Development
|