Skip to content

Memory leak while copying VImage before drawing #2733

Answered by jcupitt
MathemanFlo asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @MathemanFlo,

image = image.copy() adds a null "copy" node to a pipeline. Pixels are copied between the two images, but they will have different metadata, so you can modify one without changing the other. If you do 100 of these in a row, you'll have a pipeline 100 nodes long (!!).

If you call .draw_circle() on a pipeline, it'll allocate a memory area, render the image into it, then draw the circle. This means that every image on your 100 node pipeline will have a separate memory copy of your source image (!!).

I think what you need here is .copy_memory(). This allocates ram, renders the image into it, and returns a new image which wraps that memory area. Because it breaks the pipeline,…

Replies: 1 comment 10 replies

Comment options

You must be logged in to vote
10 replies
@jcupitt
Comment options

@MathemanFlo
Comment options

@jcupitt
Comment options

@jcupitt
Comment options

@MathemanFlo
Comment options

Answer selected by MathemanFlo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
2 participants
Converted from issue

This discussion was converted from issue #2732 on March 21, 2022 19:04.