The performance of the DataTableMetadata on initial population is suboptimal (causes our application to hang on the order of seconds to minutes). Looking at the code, it is simply backed by an array and that array has its capacity increased as necessary. Unfortunately, the algorithm implemented in the IncereaseCapacity [sic] method simply increases the array size by 1 and copies the array. This causes extreme memory churn.
I would propose that the array resizing be a little smarter, and perhaps the collection could just be backed by a List to defer the resizing responsibility (unless there was a conscious decision made as to why doubling the array on resize was not desirable).
Hi,
Thank you for your post. I have been looking into your issue and it is not a known one. Could you please attach a sample application where the reported memory leak occurs in order to investigate it on my side?
Looking forward to hearing from you.
To be clear, this is not a memory leak, it is an inefficient array resize issue.
Each time the collection needs more space, a new array of size n+1 is allocated, and the data is copied to the new array. Imagine the scenario where this array much grow in size by 10,000 or more. This results 10,000 arrays being created of average size n+5000. This is not efficient.
I have opened a support case with a sample application: CAS-148270-D9L0K3
Thank you for your reply. Let’s continue our discussion in the case.