Inventor Memory problem (** Impressive and very effective solution **)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
After having countless problems with Inventor's memory when carrying out development that processes files in batch mode (Open file, do something and close file)
It does not free the memory of the objects or files that we open, even if we close them.
The memory fills up until it throws you out because it has exceeded the memory limit that Inventor could use.
I investigated the forums to see what the Autodesk technicians said and none of the solutions do anything, we still had the problem in Inventor 2024 with the memory issue.
And I thought... Let's work on the "Inventor.exe" process to see what we can do and... I discovered it... This is the code that I call after closing a file when I am executing code on many files (The more importantly line 16😞
public static void CierraDocs()
{
if(Variables.oApp != null && Variables.oApp.Documents.Count > 0)
{
foreach (Inventor.Document doc in Variables.oApp.Documents)
{
try
{
doc.ReleaseReference();
}
catch (Exception)
{
}
}
}
Process.GetCurrentProcess().MinWorkingSet = Process.GetCurrentProcess().MaxWorkingSet - 1000;
Variables.oApp.Documents.CloseAll(true);
GC.Collect();
GC.WaitForPendingFinalizers();
}
And voila... Memory stays below 500,000k at all times.
I hope it can help all of you who have suffered the problem with your developments.