Git Product home page Git Product logo

pytracemalloc's Introduction

pytracemalloc

No Maintenance Intended

The tracemalloc module is a debug tool to trace memory blocks allocated by Python. It provides the following information:

  • Traceback where an object was allocated
  • Statistics on allocated memory blocks per filename and per line number: total size, number and average size of allocated memory blocks
  • Compute the differences between two snapshots to detect memory leaks

Quick Links:

See doc/index.rst for the source of the documentation.

pytracemalloc's People

Contributors

amirouche avatar carsonip avatar cloudhan avatar cmuller avatar elprans avatar haypoenovance avatar irachex avatar vladdoster avatar vstinner avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

pytracemalloc's Issues

Feature request: load() shouldn't require patched python

I'm running pytracemalloc to collect data in one server and then want to analyze the data in other workstations. It shouldn't be a requirement for me to install the patched python just for me to load() and analyze a cpickle file

Patches change the Python ABI

Ionel Cristian Mărieș wrote me that the patched Python has a different binary ABI, see the compilation log:
https://launchpadlibrarian.net/168954360/buildlog_ubuntu-quantal-amd64.python2.7_2.7.3-5ubuntu4.4%2Btracemalloc1.0%2Bppa1_FAILEDTOBUILD.txt.gz

The following symbols are missing:

(optional)init_hashlib
(optional)init_ssl
_PyMem_DebugFree
_PyMem_DebugMalloc
_PyMem_DebugRealloc
_PyObject_DebugCheckAddress
_PyObject_DebugCheckAddressApi
_PyObject_DebugDumpAddress
_PyObject_DebugFree
_PyObject_DebugFreeApi
_PyObject_DebugMalloc
_PyObject_DebugMallocApi
_PyObject_DebugRealloc
_PyObject_DebugReallocApi

Error installing from pip on Ubuntu 64 bit, Python 2.7.8

There seems to be the same message when readthedocs tried to build this too
https://readthedocs.org/builds/pytracemalloc/1762048/

pip install -U pytracemalloc
Downloading/unpacking pytracemalloc
  Downloading pytracemalloc-1.2.tar.gz (42kB): 42kB downloaded
  Running setup.py (path:/mnt/data/home/stu/.virtualenvs/tmpv/build/pytracemalloc/setup.py) egg_info for package pytracemalloc
    WARNING: PyMem_SetAllocator: missing, /mnt/data/home/stu/.virtualenvs/tmpv/bin/python has not been patched

    warning: no files found matching 'TODO'
Installing collected packages: pytracemalloc
  Running setup.py install for pytracemalloc
    WARNING: PyMem_SetAllocator: missing, /mnt/data/home/stu/.virtualenvs/tmpv/bin/python has not been patched
    building '_tracemalloc' extension
    x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c _tracemalloc.c -o build/temp.linux-x86_64-2.7/_tracemalloc.o -DNDEBUG
    _tracemalloc.c:50:5: error: unknown type name ‘PyMemAllocator’
         PyMemAllocator mem;
         ^
    _tracemalloc.c:51:5: error: unknown type name ‘PyMemAllocator’
         PyMemAllocator raw;
         ^
    _tracemalloc.c:52:5: error: unknown type name ‘PyMemAllocator’
         PyMemAllocator obj;
         ^
    _tracemalloc.c: In function ‘raw_malloc’:
    _tracemalloc.c:250:26: error: request for member ‘malloc’ in something not a structure or union
         return allocators.raw.malloc(allocators.raw.ctx, size);
                              ^
    _tracemalloc.c:250:48: error: request for member ‘ctx’ in something not a structure or union
         return allocators.raw.malloc(allocators.raw.ctx, size);
                                                    ^
    _tracemalloc.c: In function ‘raw_free’:
    _tracemalloc.c:256:19: error: request for member ‘free’ in something not a structure or union
         allocators.raw.free(allocators.raw.ctx, ptr);
                       ^
    _tracemalloc.c:256:39: error: request for member ‘ctx’ in something not a structure or union
         allocators.raw.free(allocators.raw.ctx, ptr);
                                           ^
    _tracemalloc.c: In function ‘tracemalloc_malloc’:
    _tracemalloc.c:511:5: error: unknown type name ‘PyMemAllocator’
         PyMemAllocator *alloc = (PyMemAllocator *)ctx;
         ^
    _tracemalloc.c:511:30: error: ‘PyMemAllocator’ undeclared (first use in this function)
         PyMemAllocator *alloc = (PyMemAllocator *)ctx;
                                  ^
    _tracemalloc.c:511:30: note: each undeclared identifier is reported only once for each function it appears in
    _tracemalloc.c:511:46: error: expected expression before ‘)’ token
         PyMemAllocator *alloc = (PyMemAllocator *)ctx;
                                                  ^
    _tracemalloc.c:514:16: error: request for member ‘malloc’ in something not a structure or union
         ptr = alloc->malloc(alloc->ctx, size);
                    ^
    _tracemalloc.c:514:30: error: request for member ‘ctx’ in something not a structure or union
         ptr = alloc->malloc(alloc->ctx, size);
                                  ^
    _tracemalloc.c:522:14: error: request for member ‘free’ in something not a structure or union
             alloc->free(alloc->ctx, ptr);
                  ^
    _tracemalloc.c:522:26: error: request for member ‘ctx’ in something not a structure or union
             alloc->free(alloc->ctx, ptr);
                              ^
    _tracemalloc.c: In function ‘tracemalloc_realloc’:
    _tracemalloc.c:532:5: error: unknown type name ‘PyMemAllocator’
         PyMemAllocator *alloc = (PyMemAllocator *)ctx;
         ^
    _tracemalloc.c:532:30: error: ‘PyMemAllocator’ undeclared (first use in this function)
         PyMemAllocator *alloc = (PyMemAllocator *)ctx;
                                  ^
    _tracemalloc.c:532:46: error: expected expression before ‘)’ token
         PyMemAllocator *alloc = (PyMemAllocator *)ctx;
                                                  ^
    _tracemalloc.c:535:17: error: request for member ‘realloc’ in something not a structure or union
         ptr2 = alloc->realloc(alloc->ctx, ptr, new_size);
                     ^
    _tracemalloc.c:535:32: error: request for member ‘ctx’ in something not a structure or union
         ptr2 = alloc->realloc(alloc->ctx, ptr, new_size);
                                    ^
    _tracemalloc.c:566:18: error: request for member ‘free’ in something not a structure or union
                 alloc->free(alloc->ctx, ptr2);
                      ^
    _tracemalloc.c:566:30: error: request for member ‘ctx’ in something not a structure or union
                 alloc->free(alloc->ctx, ptr2);
                                  ^
    _tracemalloc.c: In function ‘tracemalloc_free’:
    _tracemalloc.c:577:5: error: unknown type name ‘PyMemAllocator’
         PyMemAllocator *alloc = (PyMemAllocator *)ctx;
         ^
    _tracemalloc.c:577:30: error: ‘PyMemAllocator’ undeclared (first use in this function)
         PyMemAllocator *alloc = (PyMemAllocator *)ctx;
                                  ^
    _tracemalloc.c:577:46: error: expected expression before ‘)’ token
         PyMemAllocator *alloc = (PyMemAllocator *)ctx;
                                                  ^
    _tracemalloc.c:585:10: error: request for member ‘free’ in something not a structure or union
         alloc->free(alloc->ctx, ptr);
              ^
    _tracemalloc.c:585:22: error: request for member ‘ctx’ in something not a structure or union
         alloc->free(alloc->ctx, ptr);
                          ^
    _tracemalloc.c: In function ‘tracemalloc_malloc_gil’:
    _tracemalloc.c:598:9: error: unknown type name ‘PyMemAllocator’
             PyMemAllocator *alloc = (PyMemAllocator *)ctx;
             ^
    _tracemalloc.c:598:34: error: ‘PyMemAllocator’ undeclared (first use in this function)
             PyMemAllocator *alloc = (PyMemAllocator *)ctx;
                                      ^
    _tracemalloc.c:598:50: error: expected expression before ‘)’ token
             PyMemAllocator *alloc = (PyMemAllocator *)ctx;
                                                      ^
    _tracemalloc.c:599:21: error: request for member ‘malloc’ in something not a structure or union
             return alloc->malloc(alloc->ctx, size);
                         ^
    _tracemalloc.c:599:35: error: request for member ‘ctx’ in something not a structure or union
             return alloc->malloc(alloc->ctx, size);
                                       ^
    _tracemalloc.c: In function ‘tracemalloc_realloc_gil’:
    _tracemalloc.c:623:9: error: unknown type name ‘PyMemAllocator’
             PyMemAllocator *alloc = (PyMemAllocator *)ctx;
             ^
    _tracemalloc.c:623:34: error: ‘PyMemAllocator’ undeclared (first use in this function)
             PyMemAllocator *alloc = (PyMemAllocator *)ctx;
                                      ^
    _tracemalloc.c:623:50: error: expected expression before ‘)’ token
             PyMemAllocator *alloc = (PyMemAllocator *)ctx;
                                                      ^
    _tracemalloc.c:625:21: error: request for member ‘realloc’ in something not a structure or union
             ptr2 = alloc->realloc(alloc->ctx, ptr, new_size);
                         ^
    _tracemalloc.c:625:36: error: request for member ‘ctx’ in something not a structure or union
             ptr2 = alloc->realloc(alloc->ctx, ptr, new_size);
                                        ^
    _tracemalloc.c: In function ‘tracemalloc_raw_malloc’:
    _tracemalloc.c:655:9: error: unknown type name ‘PyMemAllocator’
             PyMemAllocator *alloc = (PyMemAllocator *)ctx;
             ^
    _tracemalloc.c:655:34: error: ‘PyMemAllocator’ undeclared (first use in this function)
             PyMemAllocator *alloc = (PyMemAllocator *)ctx;
                                      ^
    _tracemalloc.c:655:50: error: expected expression before ‘)’ token
             PyMemAllocator *alloc = (PyMemAllocator *)ctx;
                                                      ^
    _tracemalloc.c:656:21: error: request for member ‘malloc’ in something not a structure or union
             return alloc->malloc(alloc->ctx, size);
                         ^
    _tracemalloc.c:656:35: error: request for member ‘ctx’ in something not a structure or union
             return alloc->malloc(alloc->ctx, size);
                                       ^
    _tracemalloc.c: In function ‘tracemalloc_raw_realloc’:
    _tracemalloc.c:686:9: error: unknown type name ‘PyMemAllocator’
             PyMemAllocator *alloc = (PyMemAllocator *)ctx;
             ^
    _tracemalloc.c:686:34: error: ‘PyMemAllocator’ undeclared (first use in this function)
             PyMemAllocator *alloc = (PyMemAllocator *)ctx;
                                      ^
    _tracemalloc.c:686:50: error: expected expression before ‘)’ token
             PyMemAllocator *alloc = (PyMemAllocator *)ctx;
                                                      ^
    _tracemalloc.c:688:21: error: request for member ‘realloc’ in something not a structure or union
             ptr2 = alloc->realloc(alloc->ctx, ptr, new_size);
                         ^
    _tracemalloc.c:688:36: error: request for member ‘ctx’ in something not a structure or union
             ptr2 = alloc->realloc(alloc->ctx, ptr, new_size);
                                        ^
    _tracemalloc.c: In function ‘tracemalloc_init’:
    _tracemalloc.c:765:5: warning: implicit declaration of function ‘PyMem_GetAllocator’ [-Wimplicit-function-declaration]
         PyMem_GetAllocator(PYMEM_DOMAIN_RAW, &allocators.raw);
         ^
    _tracemalloc.c:765:24: error: ‘PYMEM_DOMAIN_RAW’ undeclared (first use in this function)
         PyMem_GetAllocator(PYMEM_DOMAIN_RAW, &allocators.raw);
                            ^
    _tracemalloc.c: In function ‘tracemalloc_start’:
    _tracemalloc.c:907:5: error: unknown type name ‘PyMemAllocator’
         PyMemAllocator alloc;
         ^
    _tracemalloc.c:931:10: error: request for member ‘malloc’ in something not a structure or union
         alloc.malloc = tracemalloc_raw_malloc;
              ^
    _tracemalloc.c:932:10: error: request for member ‘realloc’ in something not a structure or union
         alloc.realloc = tracemalloc_raw_realloc;
              ^
    _tracemalloc.c:933:10: error: request for member ‘free’ in something not a structure or union
         alloc.free = tracemalloc_free;
              ^
    _tracemalloc.c:935:10: error: request for member ‘ctx’ in something not a structure or union
         alloc.ctx = &allocators.raw;
              ^
    _tracemalloc.c:936:24: error: ‘PYMEM_DOMAIN_RAW’ undeclared (first use in this function)
         PyMem_GetAllocator(PYMEM_DOMAIN_RAW, &allocators.raw);
                            ^
    _tracemalloc.c:937:5: warning: implicit declaration of function ‘PyMem_SetAllocator’ [-Wimplicit-function-declaration]
         PyMem_SetAllocator(PYMEM_DOMAIN_RAW, &alloc);
         ^
    _tracemalloc.c:940:10: error: request for member ‘malloc’ in something not a structure or union
         alloc.malloc = tracemalloc_malloc_gil;
              ^
    _tracemalloc.c:941:10: error: request for member ‘realloc’ in something not a structure or union
         alloc.realloc = tracemalloc_realloc_gil;
              ^
    _tracemalloc.c:942:10: error: request for member ‘free’ in something not a structure or union
         alloc.free = tracemalloc_free;
              ^
    _tracemalloc.c:944:10: error: request for member ‘ctx’ in something not a structure or union
         alloc.ctx = &allocators.mem;
              ^
    _tracemalloc.c:945:24: error: ‘PYMEM_DOMAIN_MEM’ undeclared (first use in this function)
         PyMem_GetAllocator(PYMEM_DOMAIN_MEM, &allocators.mem);
                            ^
    _tracemalloc.c:948:10: error: request for member ‘ctx’ in something not a structure or union
         alloc.ctx = &allocators.obj;
              ^
    _tracemalloc.c:949:24: error: ‘PYMEM_DOMAIN_OBJ’ undeclared (first use in this function)
         PyMem_GetAllocator(PYMEM_DOMAIN_OBJ, &allocators.obj);
                            ^
    _tracemalloc.c: In function ‘tracemalloc_stop’:
    _tracemalloc.c:974:24: error: ‘PYMEM_DOMAIN_RAW’ undeclared (first use in this function)
         PyMem_SetAllocator(PYMEM_DOMAIN_RAW, &allocators.raw);
                            ^
    _tracemalloc.c:976:24: error: ‘PYMEM_DOMAIN_MEM’ undeclared (first use in this function)
         PyMem_SetAllocator(PYMEM_DOMAIN_MEM, &allocators.mem);
                            ^
    _tracemalloc.c:977:24: error: ‘PYMEM_DOMAIN_OBJ’ undeclared (first use in this function)
         PyMem_SetAllocator(PYMEM_DOMAIN_OBJ, &allocators.obj);
                            ^
    _tracemalloc.c: In function ‘raw_malloc’:
    _tracemalloc.c:251:1: warning: control reaches end of non-void function [-Wreturn-type]
     }
     ^
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
    Complete output from command /mnt/data/home/stu/.virtualenvs/tmpv/bin/python -c "import setuptools, tokenize;__file__='/mnt/data/home/stu/.virtualenvs/tmpv/build/pytracemalloc/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-8wlxPH-record/install-record.txt --single-version-externally-managed --compile --install-headers /mnt/data/home/stu/.virtualenvs/tmpv/include/site/python2.7:
    WARNING: PyMem_SetAllocator: missing, /mnt/data/home/stu/.virtualenvs/tmpv/bin/python has not been patched

running install

running build

running build_py

creating build

creating build/lib.linux-x86_64-2.7

copying tracemalloc.py -> build/lib.linux-x86_64-2.7

running build_ext

building '_tracemalloc' extension

creating build/temp.linux-x86_64-2.7

x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c _tracemalloc.c -o build/temp.linux-x86_64-2.7/_tracemalloc.o -DNDEBUG

_tracemalloc.c:50:5: error: unknown type name ‘PyMemAllocator’

     PyMemAllocator mem;

     ^

_tracemalloc.c:51:5: error: unknown type name ‘PyMemAllocator’

     PyMemAllocator raw;

     ^

_tracemalloc.c:52:5: error: unknown type name ‘PyMemAllocator’

     PyMemAllocator obj;

     ^

_tracemalloc.c: In function ‘raw_malloc’:

_tracemalloc.c:250:26: error: request for member ‘malloc’ in something not a structure or union

     return allocators.raw.malloc(allocators.raw.ctx, size);

                          ^

_tracemalloc.c:250:48: error: request for member ‘ctx’ in something not a structure or union

     return allocators.raw.malloc(allocators.raw.ctx, size);

                                                ^

_tracemalloc.c: In function ‘raw_free’:

_tracemalloc.c:256:19: error: request for member ‘free’ in something not a structure or union

     allocators.raw.free(allocators.raw.ctx, ptr);

                   ^

_tracemalloc.c:256:39: error: request for member ‘ctx’ in something not a structure or union

     allocators.raw.free(allocators.raw.ctx, ptr);

                                       ^

_tracemalloc.c: In function ‘tracemalloc_malloc’:

_tracemalloc.c:511:5: error: unknown type name ‘PyMemAllocator’

     PyMemAllocator *alloc = (PyMemAllocator *)ctx;

     ^

_tracemalloc.c:511:30: error: ‘PyMemAllocator’ undeclared (first use in this function)

     PyMemAllocator *alloc = (PyMemAllocator *)ctx;

                              ^

_tracemalloc.c:511:30: note: each undeclared identifier is reported only once for each function it appears in

_tracemalloc.c:511:46: error: expected expression before ‘)’ token

     PyMemAllocator *alloc = (PyMemAllocator *)ctx;

                                              ^

_tracemalloc.c:514:16: error: request for member ‘malloc’ in something not a structure or union

     ptr = alloc->malloc(alloc->ctx, size);

                ^

_tracemalloc.c:514:30: error: request for member ‘ctx’ in something not a structure or union

     ptr = alloc->malloc(alloc->ctx, size);

                              ^

_tracemalloc.c:522:14: error: request for member ‘free’ in something not a structure or union

         alloc->free(alloc->ctx, ptr);

              ^

_tracemalloc.c:522:26: error: request for member ‘ctx’ in something not a structure or union

         alloc->free(alloc->ctx, ptr);

                          ^

_tracemalloc.c: In function ‘tracemalloc_realloc’:

_tracemalloc.c:532:5: error: unknown type name ‘PyMemAllocator’

     PyMemAllocator *alloc = (PyMemAllocator *)ctx;

     ^

_tracemalloc.c:532:30: error: ‘PyMemAllocator’ undeclared (first use in this function)

     PyMemAllocator *alloc = (PyMemAllocator *)ctx;

                              ^

_tracemalloc.c:532:46: error: expected expression before ‘)’ token

     PyMemAllocator *alloc = (PyMemAllocator *)ctx;

                                              ^

_tracemalloc.c:535:17: error: request for member ‘realloc’ in something not a structure or union

     ptr2 = alloc->realloc(alloc->ctx, ptr, new_size);

                 ^

_tracemalloc.c:535:32: error: request for member ‘ctx’ in something not a structure or union

     ptr2 = alloc->realloc(alloc->ctx, ptr, new_size);

                                ^

_tracemalloc.c:566:18: error: request for member ‘free’ in something not a structure or union

             alloc->free(alloc->ctx, ptr2);

                  ^

_tracemalloc.c:566:30: error: request for member ‘ctx’ in something not a structure or union

             alloc->free(alloc->ctx, ptr2);

                              ^

_tracemalloc.c: In function ‘tracemalloc_free’:

_tracemalloc.c:577:5: error: unknown type name ‘PyMemAllocator’

     PyMemAllocator *alloc = (PyMemAllocator *)ctx;

     ^

_tracemalloc.c:577:30: error: ‘PyMemAllocator’ undeclared (first use in this function)

     PyMemAllocator *alloc = (PyMemAllocator *)ctx;

                              ^

_tracemalloc.c:577:46: error: expected expression before ‘)’ token

     PyMemAllocator *alloc = (PyMemAllocator *)ctx;

                                              ^

_tracemalloc.c:585:10: error: request for member ‘free’ in something not a structure or union

     alloc->free(alloc->ctx, ptr);

          ^

_tracemalloc.c:585:22: error: request for member ‘ctx’ in something not a structure or union

     alloc->free(alloc->ctx, ptr);

                      ^

_tracemalloc.c: In function ‘tracemalloc_malloc_gil’:

_tracemalloc.c:598:9: error: unknown type name ‘PyMemAllocator’

         PyMemAllocator *alloc = (PyMemAllocator *)ctx;

         ^

_tracemalloc.c:598:34: error: ‘PyMemAllocator’ undeclared (first use in this function)

         PyMemAllocator *alloc = (PyMemAllocator *)ctx;

                                  ^

_tracemalloc.c:598:50: error: expected expression before ‘)’ token

         PyMemAllocator *alloc = (PyMemAllocator *)ctx;

                                                  ^

_tracemalloc.c:599:21: error: request for member ‘malloc’ in something not a structure or union

         return alloc->malloc(alloc->ctx, size);

                     ^

_tracemalloc.c:599:35: error: request for member ‘ctx’ in something not a structure or union

         return alloc->malloc(alloc->ctx, size);

                                   ^

_tracemalloc.c: In function ‘tracemalloc_realloc_gil’:

_tracemalloc.c:623:9: error: unknown type name ‘PyMemAllocator’

         PyMemAllocator *alloc = (PyMemAllocator *)ctx;

         ^

_tracemalloc.c:623:34: error: ‘PyMemAllocator’ undeclared (first use in this function)

         PyMemAllocator *alloc = (PyMemAllocator *)ctx;

                                  ^

_tracemalloc.c:623:50: error: expected expression before ‘)’ token

         PyMemAllocator *alloc = (PyMemAllocator *)ctx;

                                                  ^

_tracemalloc.c:625:21: error: request for member ‘realloc’ in something not a structure or union

         ptr2 = alloc->realloc(alloc->ctx, ptr, new_size);

                     ^

_tracemalloc.c:625:36: error: request for member ‘ctx’ in something not a structure or union

         ptr2 = alloc->realloc(alloc->ctx, ptr, new_size);

                                    ^

_tracemalloc.c: In function ‘tracemalloc_raw_malloc’:

_tracemalloc.c:655:9: error: unknown type name ‘PyMemAllocator’

         PyMemAllocator *alloc = (PyMemAllocator *)ctx;

         ^

_tracemalloc.c:655:34: error: ‘PyMemAllocator’ undeclared (first use in this function)

         PyMemAllocator *alloc = (PyMemAllocator *)ctx;

                                  ^

_tracemalloc.c:655:50: error: expected expression before ‘)’ token

         PyMemAllocator *alloc = (PyMemAllocator *)ctx;

                                                  ^

_tracemalloc.c:656:21: error: request for member ‘malloc’ in something not a structure or union

         return alloc->malloc(alloc->ctx, size);

                     ^

_tracemalloc.c:656:35: error: request for member ‘ctx’ in something not a structure or union

         return alloc->malloc(alloc->ctx, size);

                                   ^

_tracemalloc.c: In function ‘tracemalloc_raw_realloc’:

_tracemalloc.c:686:9: error: unknown type name ‘PyMemAllocator’

         PyMemAllocator *alloc = (PyMemAllocator *)ctx;

         ^

_tracemalloc.c:686:34: error: ‘PyMemAllocator’ undeclared (first use in this function)

         PyMemAllocator *alloc = (PyMemAllocator *)ctx;

                                  ^

_tracemalloc.c:686:50: error: expected expression before ‘)’ token

         PyMemAllocator *alloc = (PyMemAllocator *)ctx;

                                                  ^

_tracemalloc.c:688:21: error: request for member ‘realloc’ in something not a structure or union

         ptr2 = alloc->realloc(alloc->ctx, ptr, new_size);

                     ^

_tracemalloc.c:688:36: error: request for member ‘ctx’ in something not a structure or union

         ptr2 = alloc->realloc(alloc->ctx, ptr, new_size);

                                    ^

_tracemalloc.c: In function ‘tracemalloc_init’:

_tracemalloc.c:765:5: warning: implicit declaration of function ‘PyMem_GetAllocator’ [-Wimplicit-function-declaration]

     PyMem_GetAllocator(PYMEM_DOMAIN_RAW, &allocators.raw);

     ^

_tracemalloc.c:765:24: error: ‘PYMEM_DOMAIN_RAW’ undeclared (first use in this function)

     PyMem_GetAllocator(PYMEM_DOMAIN_RAW, &allocators.raw);

                        ^

_tracemalloc.c: In function ‘tracemalloc_start’:

_tracemalloc.c:907:5: error: unknown type name ‘PyMemAllocator’

     PyMemAllocator alloc;

     ^

_tracemalloc.c:931:10: error: request for member ‘malloc’ in something not a structure or union

     alloc.malloc = tracemalloc_raw_malloc;

          ^

_tracemalloc.c:932:10: error: request for member ‘realloc’ in something not a structure or union

     alloc.realloc = tracemalloc_raw_realloc;

          ^

_tracemalloc.c:933:10: error: request for member ‘free’ in something not a structure or union

     alloc.free = tracemalloc_free;

          ^

_tracemalloc.c:935:10: error: request for member ‘ctx’ in something not a structure or union

     alloc.ctx = &allocators.raw;

          ^

_tracemalloc.c:936:24: error: ‘PYMEM_DOMAIN_RAW’ undeclared (first use in this function)

     PyMem_GetAllocator(PYMEM_DOMAIN_RAW, &allocators.raw);

                        ^

_tracemalloc.c:937:5: warning: implicit declaration of function ‘PyMem_SetAllocator’ [-Wimplicit-function-declaration]

     PyMem_SetAllocator(PYMEM_DOMAIN_RAW, &alloc);

     ^

_tracemalloc.c:940:10: error: request for member ‘malloc’ in something not a structure or union

     alloc.malloc = tracemalloc_malloc_gil;

          ^

_tracemalloc.c:941:10: error: request for member ‘realloc’ in something not a structure or union

     alloc.realloc = tracemalloc_realloc_gil;

          ^

_tracemalloc.c:942:10: error: request for member ‘free’ in something not a structure or union

     alloc.free = tracemalloc_free;

          ^

_tracemalloc.c:944:10: error: request for member ‘ctx’ in something not a structure or union

     alloc.ctx = &allocators.mem;

          ^

_tracemalloc.c:945:24: error: ‘PYMEM_DOMAIN_MEM’ undeclared (first use in this function)

     PyMem_GetAllocator(PYMEM_DOMAIN_MEM, &allocators.mem);

                        ^

_tracemalloc.c:948:10: error: request for member ‘ctx’ in something not a structure or union

     alloc.ctx = &allocators.obj;

          ^

_tracemalloc.c:949:24: error: ‘PYMEM_DOMAIN_OBJ’ undeclared (first use in this function)

     PyMem_GetAllocator(PYMEM_DOMAIN_OBJ, &allocators.obj);

                        ^

_tracemalloc.c: In function ‘tracemalloc_stop’:

_tracemalloc.c:974:24: error: ‘PYMEM_DOMAIN_RAW’ undeclared (first use in this function)

     PyMem_SetAllocator(PYMEM_DOMAIN_RAW, &allocators.raw);

                        ^

_tracemalloc.c:976:24: error: ‘PYMEM_DOMAIN_MEM’ undeclared (first use in this function)

     PyMem_SetAllocator(PYMEM_DOMAIN_MEM, &allocators.mem);

                        ^

_tracemalloc.c:977:24: error: ‘PYMEM_DOMAIN_OBJ’ undeclared (first use in this function)

     PyMem_SetAllocator(PYMEM_DOMAIN_OBJ, &allocators.obj);

                        ^

_tracemalloc.c: In function ‘raw_malloc’:

_tracemalloc.c:251:1: warning: control reaches end of non-void function [-Wreturn-type]

 }

 ^

error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

----------------------------------------
Cleaning up...
Command /mnt/data/home/stu/.virtualenvs/tmpv/bin/python -c "import setuptools, tokenize;__file__='/mnt/data/home/stu/.virtualenvs/tmpv/build/pytracemalloc/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-8wlxPH-record/install-record.txt --single-version-externally-managed --compile --install-headers /mnt/data/home/stu/.virtualenvs/tmpv/include/site/python2.7 failed with error code 1 in /mnt/data/home/stu/.virtualenvs/tmpv/build/pytracemalloc
Traceback (most recent call last):
  File "/mnt/data/home/stu/.virtualenvs/tmpv/bin/pip", line 11, in <module>
    sys.exit(main())
  File "/mnt/data/home/stu/.virtualenvs/tmpv/local/lib/python2.7/site-packages/pip/__init__.py", line 185, in main
    return command.main(cmd_args)
  File "/mnt/data/home/stu/.virtualenvs/tmpv/local/lib/python2.7/site-packages/pip/basecommand.py", line 161, in main
    text = '\n'.join(complete_log)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 50: ordinal not in range(128)

Patching pytracemalloc on Windows with Python2.7

Hi, I am trying to patch pytracemalloc on top of python27 on Windows. But I am running into the following issue:

Traceback (most recent call last):
File "setup.py", line 103, in
main()
File "setup.py", line 55, in main
pythonapi = ctypes.cdll.LoadLibrary(None)
File "C:\Python27\lib\ctypes_init_.py", line 443, in LoadLibrary
return self.dlltype(name)
File "C:\Python27\lib\ctypes_init
.py", line 365, in init
self._handle = _dlopen(self._name, mode)
TypeError: expected string or Unicode object, NoneType found

Can someone please help with this?

Handle freelists in pytracemalloc 1.0?

I almost rewritten pytracemalloc from scratch between versions 0.9 and 1.0. I wrote pytracemalloc 1.0 for Python 3.4. In this Python versions, "int" and "str" don't use freelists anymore. So tracking freelists become less important.

Python 3 uses free lists for the following object types:

  • float
  • tuple, list, set, dict
  • bound method, C function, frame

Python 2 uses free lists for the following object types:

  • int, float, unicode
  • tuple, list, set, dict
  • bound method, C function, frame

The tracemalloc module of Python 3.4 is written on top of the PEP 454 which is simpler than pytracemalloc 0.9.1 because it was not written for pytracemalloc, but to be able to use a custom memory allocator. Tracking freelists is not useful for such use case.
http://legacy.python.org/dev/peps/pep-0445/

pytracemalloc 0.9.1 had 3 options for free lists:

  • Track free lists: track all Python objects. It is the recommended option.
  • Don't track free lists: less accurate, but faster.
  • Disable free lists: track all Python objects, slower.

On embedded devices, disabling free lists killed performances and could not be used. pytracemalloc 1.0 uses the option "Don't track free lists".

Strange "No module named '_tracemalloc'" Error

➜  pytracemalloc git:(master) ✔ python3
Python 3.3.5 (default, May 12 2014, 17:35:42) 
[GCC 4.8.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import _tracemalloc
>>> 

➜  pytracemalloc git:(master) ✔ PYTHONTRACEMALLOC=1 python3
failed to start tracemalloc:
ImportError: No module named '_tracemalloc'
Python 3.3.5 (default, May 12 2014, 17:35:42) 
[GCC 4.8.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.