Message217351
Demo of calloc-5.patch on Linux. Thanks to calloc(), bytes(50 * 1024 * 1024) doesn't allocate memory for null bytes and so the RSS memory is unchanged (+148 kB, not +50 MB), but tracemalloc says that 50 MB were allocated.
$ ./python -X tracemalloc
Python 3.5.0a0 (default:4b97092aa4bd+, Apr 28 2014, 10:40:53)
[GCC 4.8.2 20131212 (Red Hat 4.8.2-7)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import os, tracemalloc
>>> os.system("grep RSS /proc/%s/status" % os.getpid())
VmRSS: 10736 kB
0
>>> before = tracemalloc.get_traced_memory()[0]
>>> large = bytes(50 * 1024 * 1024)
>>> import sys
>>> sys.getsizeof(large) / 1024.
51200.0478515625
>>> (tracemalloc.get_traced_memory()[0] - before) / 1024.
51198.1962890625
>>> os.system("grep RSS /proc/%s/status" % os.getpid())
VmRSS: 10884 kB
0 |
|
Date |
User |
Action |
Args |
2014-04-28 09:15:06 | vstinner | set | recipients:
+ vstinner, pitrou, njs, skrah, neologix, jtaylor, josh.r |
2014-04-28 09:15:06 | vstinner | set | messageid: <1398676506.19.0.732457019341.issue21233@psf.upfronthosting.co.za> |
2014-04-28 09:15:06 | vstinner | link | issue21233 messages |
2014-04-28 09:15:05 | vstinner | create | |
|