31.07.2008, 22:05 | #1 |
Участник
|
axStart: A structure way off dealing with garbage collection & memory leaks with the Dynamics AX .net connector.
Источник: http://axstart.spaces.live.com/Blog/...C0A0!364.entry
============== When reading the article on Debugging X++ Object Leaks on the weblog of the Dynamics Ax Performance team. I really start worrying about this issue. The writhers in this article tell us that each AxaptaObject and AxaptaTable must have a dispose called on it before going out of scope, or we’ll leak the object on the server with no way to clean it up. There is one quite easy rule for this issue. The object that creates an object should also dispose it. Disposing can happen on 2 ways, by the garbage collector or by your code. The last one we have in control. But how do we tell the garbage collector to clean up also my AxaptaObject and AxaptaTable. Solution: We create a wrapper class for the AxaptaObject and the AxaptaTable. This wrapper class will implement also the IDisposable interface. publicclassAXCommon : IDisposable { publicAxaptaRecord iAxObject; privatebool disposed = false; publicAxaptaRecord common { get { return iAxObject; } set { iAxObject = value; } } publicvoid Dispose() { Dispose(true); } privatevoid Dispose(bool disposing) { // Check to see if Dispose has already been called. if (!this.disposed) { // If disposing equals true, dispose all managed and unmanaged resources. if (disposing) { // Dispose managed resources. iAxObject.Dispose(); } disposed = true; } } } By the way, it is quite handy to implement additional general functions in this wrapper class. Think like all the sysdictTable functionality and other general table functionality public System.Int32 TableID() { try { return (System.Int32)iAxObject.get_Field("TableId"); } catch (Exception ex) { throw ex; } } Источник: http://axstart.spaces.live.com/Blog/...C0A0!364.entry
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору. |
|
|
Опции темы | Поиск в этой теме |
Опции просмотра | |
|