Hi,
Despite the fact that everything is released from memory the right way, the DI API version 9 with latest patch still have a memory leak. The memory growth and finally makes the system unstable and crashes the W3WP (Web Worker Process)
IIS 7
Windows Server 2008 R2 Standard
16 gig RAM (10 taken remaining 6)
Each Sales Order creation makes the W3WP process growth substentially until reaching the memory limit of the worker process which finally dies
Here's the code :
//------------------------- // Declaring SAP objects... //------------------------- SAPbobsCOM.Company CurrentCompany = null; SAPbobsCOM.Documents Order = null; SAPbobsCOM.BusinessPartners bp = null; SAPbobsCOM.Items Items = null; SAPbobsCOM.AdditionalExpenses Expenses = null; //------------------------- // Opening a company object //------------------------- SAPbobsCOM.Company CurrentCompany = GetSAPCompany(SessionID); if (CurrentCompany != null) { Order = (SAPbobsCOM.Documents)CurrentCompany.GetBusinessObject(BoObjectTypes.oOrders); bp = (SAPbobsCOM.BusinessPartners)CurrentCompany.GetBusinessObject(BoObjectTypes.oBusinessPartners); Items = (SAPbobsCOM.Items)CurrentCompany.GetBusinessObject(BoObjectTypes.oItems); Expenses = (SAPbobsCOM.AdditionalExpenses)CurrentCompany.GetBusinessObject(BoObjectTypes.oAdditionalExpenses); } //-------------------------------------------------- // Here would be the code to create a Sales Order... //-------------------------------------------------- //------------------------ // Releasing everything... //------------------------ if (Order != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(Order); Order = null; } if (bp != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(bp); bp = null; } if (Items != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(Items); Items = null; } if (Expenses != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(Expenses); Expenses = null; } if (CurrentCompany != null) { if(CurrentCompany.Connected) CurrentCompany.Disconnect(); System.Runtime.InteropServices.Marshal.ReleaseComObject(CurrentCompany); CurrentCompany = null; }