cancel
Showing results for 
Search instead for 
Did you mean: 

450Mb in an addon, how is it possible??

Former Member
0 Kudos

Hi.

I have a big problem developing addons.

When my addons starts, occupies 80mb RAM memory.

When user uses addon 3 or 4 hours my addon occupies 400 or 450Mb RAM memory.

I'm developing with VB.NET, it has 2 propierties very important

1. object's life is the block wich contain object. Ex:

        If pVal.ItemUID = "btnimport" Then
            If pVal.EventType = SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED Then
                If Not pVal.BeforeAction Then
                    Try
                        Dim oBP As SAPbobsCOM.BusinessPartners = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oBusinessPartners)

                    Catch ex As Exception
                        SBOApp.MessageBox(ex.Message)
                    End Try
		'-> oBP doesn't exists because try block is end
                End If
            End If
        End If

2. VB.NET has an utility named "<i>Garbage Collector</i>" wich is running during program life and it clean all objects wich aren't used.

So VB.NET optimizes RAM memory.

Why my addon has 450Mb???

Shall it be because Company object is overloaded and doesn't release memory???

Exists any method for releasing Company memory??

Do you know some reasons for this wild growth???

SAP Spain said me "addons are addons"

Any comments will be thankful

Thnkx

Accepted Solutions (1)

Accepted Solutions (1)

barend_morkel2
Active Contributor
0 Kudos

Hi Juli,

If your Add-On's memory usage keep growing and growing you've got a memory leak somewhere in your code. The only way to solve this is to ensure that you kill objects that you create. Also, don't leave dormant objects "laying around". Proper coding techniques include creating objects to do a task and then destroying them again. If you apply object oriented programming techniques, this should be no problem.

Also you can look at optimising your code. The processing may take more memory into use, but once the processing is done this memory should be released.

Never rely on the programming language to manage garbage collection - this will never work properly - it's based on rules which are not always appplicable. Once you've killed the object call GC.Collect to force the garbage collecter to run.

Former Member
0 Kudos

Thnx Barend

All my code is based on Create-Kill objects. Each object has a "Object = Notihng" stament, and sometimes I call Garbage Collector.

So I think problem can be in Company Object.

Somebody has any addon running with 400Mb????

Am I the once???

Please comment me your case!!!!!

barend_morkel2
Active Contributor
0 Kudos

Hi Juli,

I have a lot of Add-Ons running on multiple sites and the Company Object has never created a memory leak. Thus I don't think your problem lies there.

It's more work but ensure that each object that you create is killed usign the suggested kill mechanism:

<b>

start proc/func

DIM Obj

try

'do your stuff

except

'mayge some exception handling/error reporting

finally

Obj = nothing

System.Runtime.InteropServices.Marshal.ReleaseComObject(Obj )

GC.Collect()

end try

end proc/func</b>

This will ensure that the object always gets killed even if an error occurs.

I gaurentee if you apply this logic to all your procs/funcs - your memory leak will be sorted out..

Former Member
0 Kudos

Hi!

Thnx for your reply,

I will try with

System.Runtime.InteropServices.Marshal.ReleaseComObject(Obj)

I never used this stament and I think this is a good option

Thnx for all!!

Former Member
0 Kudos

Hi people

I tried with

System.Runtime.InteropServices.Marshal.ReleaseComObject(Obj)

and release 5 o 6 mb only.....

somebody has another idea, please????

Thnx!!!!

Former Member
0 Kudos

Hi,

You only mentioned the System.Runtime.InteropServices.Marshal.ReleaseComObject(Obj)

Just be sure that you are using all 3 lines together on ALL of your objects. I don't think just that one line by itself will clean up everything.

Obj = nothing

System.Runtime.InteropServices.Marshal.ReleaseComObject(Obj)

GC.Collect()

The above should fix it but if after that you are still having a leak, you will probably need to just step through your program. That is time consuming but you should be able to see exactly where the memory is increasing and not being released to narrow it down.

Paul

barend_morkel2
Active Contributor
0 Kudos

Hi Juli,

As Ihave mentioned: you have to apply the "try-catch-finally" logic with the "release of all objects created" to all your procs/funcs - each and every one in your entire application...

Former Member
0 Kudos

Hi Paul,

I agree that you should set the COM object to null but you have to do it after releasing it with InteropServices. Using C# you get an "Object reference not set to an instance of an object" error. I think it will be the same in VB.

I think this solution might help if you are only reading data via DI objects. Still this does not help if you want to write to the database.

We have got a similar problem with memory leaks which occurs after adding COM objects (e.g. Documents object). The Add-On caused the swap file to grow up to 2GB and after that BO died. Up to now we have no idea how to fix it or if we are actually able to fix it. If anybody has feel welcome to answer

Regards,

Jan Wehrs

Former Member
0 Kudos

Hi people.

Thnx for your answers.

I forgot call us that I put the 3 sentences

Obj = nothing
System.Runtime.InteropServices.Marshal.ReleaseComObject(Obj)
GC.Collect()

And the result is the same.

Jan, your executable file catch 2Gb in RAM memory????

Somebody has any reason for this??????

Thnx gurus!!!!

Former Member
0 Kudos

Buenas,

Just some questions to identify where the problem is:

- Does memory grow when you don´t use SBO?

- Does memory grow when certain processes are done?

- Have you got event filters?

- Does the memory grow allways with the same size?

- How much time does it take to grow until the 450MB?

Regards,

Ibai

Answers (4)

Answers (4)

Former Member
0 Kudos

SAP marketplace answer :

_____________________________________________________________

I have just received feedback from our development. The have advised

us that this problem is now a candidate to be fixed in a future

version. They have created note 1002513. This note has not been

released yet, but will hopefully be released shortly.

_____________________________________________________________

Sébastien

Former Member
0 Kudos

Any news?

Gianluigi
Product and Topic Expert
Product and Topic Expert
0 Kudos

What about profiling your add-on with some .NET memory

profiling tool ? there are some available on the net.

You should make the analysis that Ibai is suggesting,

finding the scenarios that make your add-on leak,

and then profile the execution and find the objects not

released.

Former Member
0 Kudos

Hello,

I have the same problem.

I have an addon that only access to the database (only DI objects) to create user Table & Fields.

This addon creates about 70 tables and about 900 fields.

This creation takes more than 2 hours to be done.

when I start it, it is about 100Mo, but then it grows up and can be also about 400 to 500 Mo.

at the beginning, it takes less than 1 second to create a userfields, but then it can take more than 3-4 seconds, I don't even know at the end because I kill the process before.

the add On call the funtcion Add or update of the UserfeldsMD object only if it needs to be done. If the database is correct, these function are not called.

Once all the fields are created, it takes less than 2 minutes to check if all the fields are OK.

I do release every single object after I use them.

I downloaded this program, but it didin't really help me.

http://www.red-gate.com/products/ants_profiler/index.htm

The addOn memory used (as it can be seen in the task manager) is always a lot higher than the memory defined in the result of the program.

I'm also looking for a way to reduce the size, and I check a lot of time, I don't see any memory leak in this small program.

Sebastien

Former Member
0 Kudos

Hi people!

Buenas Ibai!!!

I think Sébastien has key of question.

I ever thought company object has a big bug.

Why???

I think each time you have .add in DI Objects, company object catch memory and never release it.

Is it possible???

Sébastien's addon is very simple, only creates Tables and Fields. Only 2 instructions, Create table an Create Field and his addon grows about 500Mb, is it normal???

How is possible????

Has any sense my "theory" about Company object never release memory????

Some SAP people has answer for Sébastien problem???

Thnx in advance

Former Member
0 Kudos

Buenas,

I don´t think the problem is so easy to detect. There are lots of addons installed around the world that work, consuming 80, 90 or 120 MB.

I don´t think is a general company objects bug, becouse then the problems would be more clear (much more partners asking about it.).

It would be good that Sebastian can create a minimal addon to reproduce the issue.

But Juli, try to answer the questions on my post before.

Regards,

Ibai Peña

PD: De que partner eres? Mandame un email a itasoporteARROBAitaktion.com y quiza pueda ayudarte mas a fondo.

Former Member
0 Kudos

Hola,

I have a small AddOn sample that reproduce the problem.

It creates in one time 80 tables with 15 fields each. After 800 fields, each field takes more than 5 seconds to be created, and the memory is about 340 Mo.

I created A SAP Note and I will update this post as soon as I have news from them

Sebastien

Message was edited by: Sébastien Danober

former_member201110
Active Contributor
0 Kudos

Hi all,

It might be worth mentioning that the SAP Fixed Assets add-on has the same problem. When you first install it and start it up, the add-on tries to create a large number of UDFs and UDTs. The add-on will start eating vast amounts of memory (and yes, I've seen it take 1-2GB!) and eventually will cause an error and stop.

This has been an issue with the add-on since I started working with SBO, i.e. from 2004A to 2005A SP1.

Regards,

Owen

Former Member
0 Kudos

Hi Sebastien,

Please do update once you get news from SAP, it will be very interesting and useful to watch this thread.

regards,

Indika.

Former Member
0 Kudos

Hi,

I don't really trust the VB.NET Garbage Collector to handle things on it's own. I did in the beginning and had huge memory leaks. Once I started to explicitly clean up my objects and call the garbage collector everytime things worked much better.

The SAPbobsCOM Objects such as RecordSets and business objects like the .BusinessPartners seem to love memory and did not get cleaned up that well, unless I explcitly told VB.NET to release them.

Try the following couple of lines of code as soon as you are done with the object. This will release the object from VB.NET.

'oRec is a RecordSet

System.Runtime.InteropServices.Marshal.ReleaseComObject(oRec)

GC.Collect()

Gianluigi
Product and Topic Expert
Product and Topic Expert
0 Kudos

The MB of memory used at the beginning are occupied when

you connect to the company. But for what it concerns the

400 M your solution occupies look like you have a leak in

your application.

Former Member
0 Kudos

Hi Gianluigi. Thnx

It's possible that I have a leak in my application, in fact it will be, but what type of leaks causes this problem.

Today, my addon was in 500mb

Thnx in advance!