2009 Aug 06 4:08 PM
Hello.
Im currently programming on a project in VB.NET that creates Materials and Materialclassifications in SAP using Textfiles created by our CAD-System and that 24/7. The Program works just fine, but I have located a memory leak which lets the application grow until the end of dawn.
Almost every example code ive come across suggested that i instance the connection directly into the BAPI Object like
objBAPICtrl.Connection = objLogonCtrl.NewConnection
Since I needed both, BAPI and Functions, I went on declaring one connection object in the middle for both:
pSAPLogonControl = CreateObject("SAP.Logoncontrol.1")
pSAPConnection = pSAPLogonControl.NewConnection
'...Login data und the login itself here...
If pSAPConnection IsNot Nothing Then
objBAPICtrl.Connection = pSAPConnection
objfunctionCtrl.Connection = pSAPConnection
End If
Works great, but here is the memory leak. Ive found out that, for some reason, there is no "clear" method for the BAPI Control. So all values I have declared in the objects for the BAPI like this
objStandardMaterial = objBAPICtrl.GetSAPObject("StandardMaterial")
objHeadData = objBAPICtrl.DimAs(objStandardMaterial, "SaveData", "HeadData")
...
keep their values, even after a "Nothing". Well, VB.NET tells me they havent been declared, but as soon as I declare them again as above, the values are all back.
The only way to clear the values, Ive found, is to "Nothing" the objBAPICtrl and assign the connection object again. Here comes in the memory leak. Every time I NULL the objBAPICtrl and reassign the connection object I create a new instance (Ive tested this with the .NET Memory Profiler). BTW, the same applies to the SAP Functions Control.
Well, here are the two ways Ive got now:
1. After every single Material ive created/modified in SAP, I have to logoff, destroy the BAPI Control, create the BAPI Control and logon to SAP again. Sounds good and clean, but is horribly slow.
2. Find some way to reassign the connection to the BAPI Control (and Function Control) without creating a new instance every time.
Anybody got an idea?
Greets,
Michael Weinstabl
Hello.
Im currently programming on a project in VB.NET that creates Materials and Materialclassifications in SAP using Textfiles created by our CAD-System and that 24/7. The Program works just fine, but I have located a memory leak which lets the application grow until the end of dawn.
Almost every example code ive come across suggested that i instance the connection directly into the BAPI Object like
objBAPICtrl.Connection = objLogonCtrl.NewConnection
Since I needed both, BAPI and Functions, I went on declaring one connection object in the middle for both:
pSAPLogonControl = CreateObject("SAP.Logoncontrol.1")
pSAPConnection = pSAPLogonControl.NewConnection
'...Login data und the login itself here...
If pSAPConnection IsNot Nothing Then
objBAPICtrl.Connection = pSAPConnection
objfunctionCtrl.Connection = pSAPConnection
End If
Works great, but here is the memory leak. Ive found out that, for some reason, there is no "clear" method for the BAPI Control. So all values I have declared in the objects for the BAPI like this
objStandardMaterial = objBAPICtrl.GetSAPObject("StandardMaterial")
objHeadData = objBAPICtrl.DimAs(objStandardMaterial, "SaveData", "HeadData")
...
keep their values, even after a "Nothing". Well, VB.NET tells me they havent been declared, but as soon as I declare them again as above, the values are all back.
The only way to clear the values, Ive found, is to "Nothing" the objBAPICtrl and assign the connection object again. Here comes in the memory leak. Every time I NULL the objBAPICtrl and reassign the connection object I create a new instance (Ive tested this with the .NET Memory Profiler). BTW, the same applies to the SAP Functions Control.
Well, here are the two ways Ive got now:
1. After every single Material ive created/modified in SAP, I have to logoff, destroy the BAPI Control, create the BAPI Control and logon to SAP again. Sounds good and clean, but is horribly slow.
2. Find some way to reassign the connection to the BAPI Control (and Function Control) without creating a new instance every time.
Anybody got an idea?
Greets,
Michael Weinstabl
2009 Aug 06 8:09 PM
Hello,
Hope you have opened SAP OSS ticket as this is memory leak issue it must be known issue and you may find some notes on SAP
market place. so, i will suggest to search notes and open oss ticket.
Thanks,
Augustin.