summaryrefslogtreecommitdiff
path: root/test/isurface_create_for_data_memleak.py
blob: d07287f748e29faa355384c7716ba296d7b7a772 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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