GC.Collect() cannot guarantee that all memory will be collected.
Use this method to try to reclaim all memory that is inaccessible. It performs a blocking garbage collection of all generations.
All objects, regardless of how long they have been in memory, are considered for collection; however, objects that are referenced in managed code are not collected.
You can also take a look at the discussion on this issue in this post:
.NET Garbage Collection behavior (with DataTable obj)
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.