我正在尝试嵌入一个只能在缓冲区中给我一个 bmp 图像的图表抽屉库。
我正在加载这个图像,并且必须在新创建的 pixbuf 上显式调用 delete,然后调用垃圾收集器。
绘图方法每 50ms 调用一次
调用垃圾收集器确实很消耗 CPU。
有没有办法让所有进程只有一个 pixbuf,因此不必调用 gc?
还是我做错了一切?
提前谢谢任何帮助
拉斐尔
代码:
def draw(self, drawArea):
#init bmp loader
loader = gtk.gdk.PixbufLoader ('bmp')
#get a bmp buffer
chart = drawArea.outBMP2()
#load this buffer
loader.write(chart)
loader.close()
#get the newly created pixbuf
pixbuf = loader.get_pixbuf()
#and load it in the gtk.Image
self.img.set_from_pixbuf(pixbuf)
del pixbuf
gc.collect()