I am running macOS version 10.14.6 and the simplified script works perfectly fine on my machine as well.
As I was trying to extend it I got the same output again and I did some trial and error.
What am I trying to achieve?
I have in mind a setup where I draw an ImageObject. The ImageObject then can contain text or graphics as well as another image. I then feed it into some arbitrary function to manipulate it.
The clue is that I want to manipulate the manipulated image again. So I am currently returning a new ImageObeject from the manipulation function.
I came up with something like this:
w = h = 300
# higher Numbers here result in the context leak
numManipulations = 20
def manipulateImage(img, r, angle, pos):
tempImg = ImageObject()
x, y = pos
# Draw the old Image
image(img, (0, 0))
# Draw the manipulation on top
oval(x - r, y - r, r * 2, r * 2)
rotate(angle, center = (x, y))
image(img, (0, 0))
im = ImageObject()
rect(0, 0, w, h)
text("Heee", (10, 10))
for a in range(numManipulations):
r = randint(20, 40)
x = randint(r, w-r)
y = randint(r, h-r)
angle = randint(0, 360)
im = manipulateImage(im, r, angle, (x, y))
image(im, (0, 0))
What I found out so far:
The scripts runs fine when you only save the final image.
Nope, running 100 repetitions results in the same
When I am trying to save every step for animation purpose or so I will get
Context leak deteced, msgtracer -1. No matter using
png for later stitching.
png it usually starts at around 12 repetitions,
gif can go up to 100 repetitions, but I guess it depends on the resolution and other factors.
Running the script within the app you see no problem except on a lot of repetitions the app freezes at some point and you need to kill it. Running the same script then in Terminal you see the
Context leak deteced, msgtracer -1.
Maybe it is not the best setup for what I have in mind, but I hope one can understand what's happening.
Any input for improvment is much appreciated as well.