I created a PowerShell script which loops over a large number of XML Schema (.xsd) files, and for each creates a .NET XmlSchemaSet object, calls Add() and Compile() to add a
After the remove-variable you can try to force GC collection :
remove-variable
[GC]::Collect()