diff options
Diffstat (limited to 'test/isurface_create_for_data_memleak.py')
-rwxr-xr-x | test/isurface_create_for_data_memleak.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/test/isurface_create_for_data_memleak.py b/test/isurface_create_for_data_memleak.py new file mode 100755 index 0000000..d07287f --- /dev/null +++ b/test/isurface_create_for_data_memleak.py @@ -0,0 +1,28 @@ +#!/usr/bin/env python +"""test cairo.ImageSurface.create_for_data() for memory leaks +""" + +import array +import resource + +import cairo + + +pagesize = resource.getpagesize() + +if not (cairo.HAS_IMAGE_SURFACE and cairo.HAS_PNG_FUNCTIONS): + raise SystemExit ('cairo was not compiled with ImageSurface and PNG support') + +width, height = 255, 255 +lst = [0] * width * height * 4 + +c = 1 +while True: + for i in range(50): + data = array.array('B', lst) + surface = cairo.ImageSurface.create_for_data(data, cairo.FORMAT_ARGB32, + width, height) + ctx = cairo.Context(surface) + + print(c, resource.getrusage(resource.RUSAGE_SELF).ru_maxrss * pagesize) + c += 1 |