AXForum  
Вернуться   AXForum > Microsoft Dynamics AX > DAX Blogs
DAX
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 31.07.2008, 22:05   #1  
Blog bot is offline
Blog bot
Участник
 
25,486 / 846 (79) +++++++
Регистрация: 28.10.2006
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, напишите личное сообщение администратору.
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
axStart: Microsoft Dynamics AX 2009 Hot Topics Web Seminar Series Blog bot DAX Blogs 0 06.08.2008 12:05
Inside Dynamics AX 4.0: Working with the .NET Business Connector Blog bot DAX Blogs 0 04.10.2007 05:15
Inside Dynamics AX 4.0: Usage Scenarios Blog bot DAX Blogs 0 04.10.2007 05:15
Inside Dynamics AX 4.0: Inside the Business Connector Blog bot DAX Blogs 0 04.10.2007 05:15
ALEG: Проект "Фишка недели" и первый пост - Microsoft Dynamics™ AX .NET Business Connector Blog bot DAX Blogs 1 22.11.2006 09:43

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 01:58.
Powered by vBulletin® v3.8.5. Перевод: zCarot
Контактная информация, Реклама.