Skip to content

Memory leak #1

Description

@DeltaFlight

Union consumes about 500 Kb per sphere, though not producing new vertices.
Following program was run on a machine with 512Mb memory limit, crashed after making union of 800 identical spheres.

!/usr/bin/python

import sys
import math

from cadmium import *

def memory_usage():
"""Memory usage of the current process in MB."""
status = None
result = {'peak': 0, 'rss': 0}
try:
status = open('/proc/self/status')
for line in status:
parts = line.split()
key = parts[0][2:-1].lower()
if key in result:
result[key] = int(parts[1]) / 1024
finally:
if status is not None:

        status.close()
return result

s = Sphere(r = 5, center = True)
a = s

n = int(sys.argv[1])
for i in xrange(0, n):
s = s + a
if (i % 100) == 0:
print "i =", i, "mem usage", memory_usage()

s.toSTL("1.stl")

Output was:

deltaflight@natty32:~$ time python loop.py 900
i = 0 mem usage {'peak': 148, 'rss': 79}
i = 100 mem usage {'peak': 197, 'rss': 127}
i = 200 mem usage {'peak': 247, 'rss': 176}
i = 300 mem usage {'peak': 297, 'rss': 225}
i = 400 mem usage {'peak': 350, 'rss': 277}
i = 500 mem usage {'peak': 400, 'rss': 325}
i = 600 mem usage {'peak': 450, 'rss': 374}
i = 700 mem usage {'peak': 499, 'rss': 422}
i = 800 mem usage {'peak': 554, 'rss': 462}
Killed

real 2m6.949s
user 0m25.714s
sys 1m10.208s

deltaflight@natty32:~$ dmesg |tail -2
[ 3123.445580] Out of memory: Kill process 1101 (python) score 934 or sacrifice child
[ 3123.445833] Killed process 1101 (python) total-vm:607704kB, anon-rss:474520kB, file-rss:24kB

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions