google-code-export / pyglet

Automatically exported from code.google.com/p/pyglet
BSD 3-Clause "New" or "Revised" License
1 stars 1 forks source link

Memory leak in pyglet.image.load #552

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Windows 7 64-bit, Python 2.7.2 (32-bit), pyglet 1.1.4 installed by pip install 
pyglet

---

import pyglet

fn = 'C:\Users\Public\Pictures\Sample Pictures\Koala.jpg'

while True:
    pyglet.image.load(fn)
    # watch the memory usage grow

---

Original issue reported on code.google.com by michal....@gmail.com on 5 Feb 2012 at 9:44

Attachments:

GoogleCodeExporter commented 9 years ago
This does *not* happen on Ubuntu 11.10 64-bit with Xvfb server and pyglet & 
python 2.7 installed by apt-get.

Original comment by michal....@gmail.com on 5 Feb 2012 at 9:56

GoogleCodeExporter commented 9 years ago
The image decoder where the leak occurs is 
pyglet.image.codecs.gdiplus.GDIPlusDecoder, so this is Windows-only. Also, as 
it looks from the comments in gdiplus.py it looks like there is a "TODO:" about 
releasing Stream object. Perhaps this is the source of this leak.

Original comment by michal....@gmail.com on 5 Feb 2012 at 3:37

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
As it looks like IStream::Release should be also called, and I have no idea how 
to do this, I am currently looking for help at StackOverflow here 
http://stackoverflow.com/questions/9151191/python-pyglet-win32-api-com-how-to-ca
ll-istreamrelease-if-all-i-have-is-a 

Original comment by michal....@gmail.com on 5 Feb 2012 at 5:53

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Possible fix, that I created after reading Alex's answer on StackOverflow - 
available here - http://code.google.com/r/michaldtz-fix-552

Original comment by michal....@gmail.com on 20 Feb 2012 at 10:09

GoogleCodeExporter commented 9 years ago
Here's the diff: 
http://code.google.com/r/michaldtz-fix-552/source/diff?spec=svn51cda2e42f0ff771f
31ccda226fcd884c912d7ca&old=726ba581782d2ce55d0f9c90f161e57c97da10ca&r=51cda2e42
f0ff771f31ccda226fcd884c912d7ca&format=unidiff&path=%2Fpyglet%2Fimage%2Fcodecs%2
Fgdiplus.py

Original comment by michal....@gmail.com on 20 Feb 2012 at 10:16

GoogleCodeExporter commented 9 years ago

Original comment by michal....@gmail.com on 20 Feb 2012 at 10:36

Attachments:

GoogleCodeExporter commented 9 years ago
windows XP sp3 - Python 2.7 - pyglet 1.1.4
That patch works for me.
I use to have memory leak loading and displaying a lot of Images. Even if I 
removed them properly after used.
Now, memory is stable.
Comes from here 
http://groups.google.com/group/cocos-discuss/browse_thread/thread/4865654f7eb7fd
a0

Original comment by philippe...@gmail.com on 24 Apr 2012 at 1:06

GoogleCodeExporter commented 9 years ago

Original comment by useboxnet on 17 Jul 2013 at 4:59

GoogleCodeExporter commented 9 years ago
This issue was closed by revision 7d0ddfa8f7d0.

Original comment by useboxnet on 21 Sep 2013 at 10:43

GoogleCodeExporter commented 9 years ago
Thank you!

Original comment by michal....@gmail.com on 21 Sep 2013 at 12:52