Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 17 Mar 2011 20:13:03 +0530
From:      Amit Dev <amitdev@gmail.com>
To:        freebsd-python@freebsd.org
Subject:   Python malloc issue?
Message-ID:  <AANLkTikifWXgzzjm-P84d3Zq-ufZO4g5TugZsaQhBdmV@mail.gmail.com>

next in thread | raw e-mail | index | archive | help
I'm observing a strange memory usage pattern with python strings on
Freebsd. Consider
the following session. Idea is to create a list which holds some
strings so that cumulative characters in the list is 100MB.

>>> l = []
>>> for i in xrange(100000):
...  l.append(str(i) * (1000/len(str(i))))

This uses around 100MB of memory as expected and 'del l' will clear that.

>>> for i in xrange(20000):
...  l.append(str(i) * (5000/len(str(i))))

This is using 165MB of memory. I really don't understand where the
additional memory usage is coming from. [Size of both lists are same]

Python 2.6.4 on FreeBSD 7.2. On Linux and windows both uses around
100mb memory only.

Regards,
aMit



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?AANLkTikifWXgzzjm-P84d3Zq-ufZO4g5TugZsaQhBdmV>