Vahsi Uzman 1
Vahsi Uzman
Bvural41 1
Bvural41
Hikaye Ekle

ImageBox memory leak fix

  • Konuyu başlatan Konuyu başlatan Koray'
  • Başlangıç tarihi Başlangıç tarihi
  • Cevaplar Cevaplar 19
  • Görüntüleme Görüntüleme 6K

HERAKLES Otomatik Avlı kalıcı sunucu. 19 Haziran'da açılıyor. Atius & Wizard güvencesiyle hemen kayıt ol, ön kayıt ödülleri aktif. HEMEN TIKLA!

Oyun içerisinde ImageBox kullanan UI eklentileriniz varsa oyun penceresi açık olduğu sürece(relog atmadığınız sürece vs) pencereyi kapatsanız bile içerisindeki resimler hafızadan silinmiyor ve her açılışta yeniden yükledikçe hafıza artışına sebep oluyor, bunun çözümünü paylaşıcam.

Öncesi:
b.png

Sonrası:
a.png


* EterPythonLib\PythonWindowManagerModule.cpp

Arat:
Kod:
PyObject* wndImageLoadImage(PyObject* poSelf, PyObject* poArgs)
{
...
}

Altına ekle:
Kod:
PyObject* wndImageUnloadImage(PyObject* poSelf, PyObject* poArgs)
{
    UI::CWindow* pWindow;
    if (!PyTuple_GetWindow(poArgs, 0, &pWindow)) {
        return Py_BuildException();
    }

    if (!((UI::CImageBox*)pWindow)->UnloadImage()) {
        return Py_BuildException("Failed to unload image");
    }

    return Py_BuildNone();
}

Arat:
Kod:
        { "LoadImage",                    wndImageLoadImage,                    METH_VARARGS },

Altına ekle:
Kod:
        { "UnloadImage",                 wndImageUnloadImage,                METH_VARARGS },

---

* EterPythonLib\PythonWindow.cpp

Arat:
Kod:
    BOOL CImageBox::LoadImage(const char* c_szFileName)
    {
...
    }

Altına ekle:
Kod:
    BOOL CImageBox::UnloadImage()
    {
        if (!m_pImageInstance)
            return FALSE;

        OnDestroyInstance();
        return TRUE;
    }

---

* EterPythonLib\PythonWindow.h

Arat:
Kod:
        BOOL LoadImage(const char* c_szFileName);

Altına ekle:
Kod:
        BOOL UnloadImage();

---

* root/ui.py

Arat:
Kod:
class ImageBox(Window):

Bul:
Kod:
        self.eventFunc = {}
        self.eventArgs = {}

Altına ekle:
Kod:
        self.imageLoaded = False

---

Arat:
Kod:
wndMgr.LoadImage(self.hWnd, imageName)

Altına ekle:
Kod:
self.imageLoaded = True

---

Arat:
Kod:
def __del__(self):

Altına ekle:
Kod:
        if self.imageLoaded:
            self.UnloadImage()

---

Dosyada "UnloadImage" fonksiyonu yoksa;

Arat:
def SetAlpha(self, alpha):

Üstüne ekle:
Python:
    def UnloadImage(self):
        wndMgr.UnloadImage()
        self.imageLoaded = False

        if len(self.eventDict) != 0:
            print "UNLOAD IMAGE", self, self.eventDict
 
Son düzenleme:

En Çok Reaksiyon Alan Mesajlar

Python:
    def UnloadImage(self):
        wndMgr.UnloadImage(self.hWnd)
        self.imageLoaded = False

        if len(self.eventDict) != 0:
            print "UNLOAD IMAGE", self, self.eventDict
Öğeyi görmek için üye olmalısınız.

Şu an konuyu görüntüleyenler (Toplam : 0, Üye: 0, Misafir: 0)

Geri
Üst