TuZaKK 1
TuZaKK
Mt2Hizmet 1
Mt2Hizmet
Agora Metin2 1
Agora Metin2
Bvural41 1
Bvural41
kaptanmikro1 1
kaptanmikro1
R 1
Roksam
[DEV]AB 1
[DEV]AB
Sevdamsın 1
Sevdamsın
farkmt2official 1
farkmt2official
emirhanHCL 1
emirhanHCL
Scarlet 1
Scarlet
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

Türkiye'de ilk Mobil & PC Aynı Anda Metin2 Oyna. Triarchonline kalıcı ve uzun ömürlü yapısı ile 24 Temmuz'da açılıyor. | 1-99 Mobil Metin2 Triarch 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