Sign up

how to free a pixbuf object?

I want to processing lots of image (scale it). so, create a pixbuf object in every thread to processing image.

srcPixbuf = new Pixbuf(/path/to/image/file);

resize image and save. after processing some image, program report OutOfMemory error.

I think, maybe need to free pixbuf object everytime. But, the method of free pixbuf object was not found. How to free a pixbuf object ?

Re: how to free a pixbuf object?

On 9/23/18 12:45 PM, huangyy wrote:

I want to processing lots of image (scale it). so, create a pixbuf object in every thread to processing image.

srcPixbuf = new Pixbuf(/path/to/image/file);

resize image and save. after processing some image, program report OutOfMemory error.

I think, maybe need to free pixbuf object everytime. But, the method of free pixbuf object was not found. How to free a pixbuf object ?

You can use the destroy function from druntime/object.

srcPixbuf.destroy();

https://dlang.org/phobos/object.html#.destroy

Re: how to free a pixbuf object?

On Sun, 23 Sep 2018 14:33:26 +0200, Mike Wey wrote:

On 9/23/18 12:45 PM, huangyy wrote:

I want to processing lots of image (scale it). so, create a pixbuf object in every thread to processing image.

srcPixbuf = new Pixbuf(/path/to/image/file);

resize image and save. after processing some image, program report OutOfMemory error.

I think, maybe need to free pixbuf object everytime. But, the method of free pixbuf object was not found. How to free a pixbuf object ?

You can use the destroy function from druntime/object.

srcPixbuf.destroy();

https://dlang.org/phobos/object.html#.destroy

It's not work :( , same error report.

Re: how to free a pixbuf object?

On 9/24/18 8:47 AM, huangyy wrote:

It's not work :( , same error report.

Do you have something i could test with?

Re: how to free a pixbuf object?

On Mon, 24 Sep 2018 19:11:08 +0200, Mike Wey wrote:

On 9/24/18 8:47 AM, huangyy wrote:

It's not work :( , same error report.

Do you have something i could test with?

I have solved this problem. :)
Gobject memory management does not depend on D's GC. using gobject's unref to free a gobject.

srcPixbuf.unref();

Re: how to free a pixbuf object?

On 9/25/18 10:45 AM, huangyy wrote:

On Mon, 24 Sep 2018 19:11:08 +0200, Mike Wey wrote:

On 9/24/18 8:47 AM, huangyy wrote:

It's not work :( , same error report.

Do you have something i could test with?

I have solved this problem. :)
Gobject memory management does not depend on D's GC. using gobject's unref to free a gobject.

srcPixbuf.unref();

Great,

Technically destroy should run the destructor witch calls unref, so
i'll need to check why that doesn't work.