cancel
Showing results for 
Search instead for 
Did you mean: 

Memory Deallocation for a Screen

former_member313593
Participant
0 Kudos

Good Afternoon

Experts:

I just found today a problem with memory allocation with my screens. When I open a screen the memory allocation for the .net Add-on naturally increases. The problem is when I exit the sceen...it does not go back down. I have made sure that the Form_Count has been subtracted and the Dispose() Sub has been called.

That Sub includes setting my Form, Item, Package, Button, Textbox and datasoruce all equal to Nothing. I also call Systems.GC.Collect(). Still, the memory is not reduced at all. So, when opening the screen and closing then opening again, the memory grows to a point where the application becomes sluggish.

Is there anything else I need to be setting to Nothing? Is there any other System function that I need to be calling?

Thanks,

EJD

Accepted Solutions (1)

Accepted Solutions (1)

former_member201110
Active Contributor
0 Kudos

Hi,

I've never heard of the UI API having a memory leak. I've certainly come across leaks in the DI API, most noticeable if your add-on performs a loop while adding transactions or metadata objects.

You could try using the following commands to force garbage collection and see if this improves the situation (C#):

System.Runtime.InteropServices.Marshal.ReleaseComObject(MyCOMObject);

GC.Collect();

where MyCOMObject is the UI API or DI API object you've instantiated.

Kind Regards,

Owen

former_member313593
Participant
0 Kudos

Owen:

Your response is appreciated. It appears we came to the same conclusion. I had a RecordSet object that was allocating 6K+ in memory and not getting released.

Now, I am getting that memory back and still have to search for the cause of the remaining loss. Is it recommened to release every object, after use, that is created using the method that you suggested?

Thanks,

EJD

former_member201110
Active Contributor
0 Kudos

Hi,

Yes, I'd recommend that you use the code above for releasing any DI API object. Mostly I find memory issues with the Metadata objects (ie creating UDFs and UFTs) and marketing documents. The performance hit is minimal and it makes a better job or releasing the memory so I tend to use it in most cases. Most DI API objects don't leak but I prefer to try and bulletproof my add-ons

Kind Regards,

Owen

Answers (0)