Notifications
Clear all

2261279 - DI API:How To Handle Memory Leak In COM Objects

1 Posts
1 Users
0 Likes
162 Views
admin
Posts: 339
Admin
Topic starter
(@admin)
Prominent Member
Joined: 3 years ago

Symptom

When using Data Interface API (DI API) COM objects, you find memory is not released and API actions are slow.

Cause

System behavior/ Functionality description/ Business process

Solution

For the best performance and memory handling consider below recommendation.

  • Use one Company connection per database schema and avoid repeated connections.
  • In general, it should be sufficient to initialize the object once and release the object at the end of a loop.
  • Declare & instantiate COM objects at the last moment possible.
  • ReleaseComObject(obj) or FinalReleaseComObject(obj) for ALL objects, at the soonest moment possible.
  • Always ReleaseComObject(obj) or FinalReleaseComObject(obj) in the opposite order of creation.
  • NEVER call GC.Collect() except when required for debugging.
  • If you are planning to create a program which will be running for several hours continuously, or creating 1000's of documents with multiple child objects, then explicit memory release should be considered.
  • If you running a DI API program as a windows service, it is recommended to schedule a restart at least once a day.

Example with respect to DI API, adding Sales Order

Reply
Share:
x  Powerful Protection for WordPress, from Shield Security
This Site Is Protected By
Shield Security