bloomberg / memray

Memray is a memory profiler for Python
https://bloomberg.github.io/memray/
Apache License 2.0
13.36k stars 397 forks source link

is memray support profiling c version of python package like pillow? #526

Closed zdyj3170101136 closed 10 months ago

zdyj3170101136 commented 10 months ago

is memray support profiling c version of python package like pillow?

godlygeek commented 10 months ago

Yes, see https://bloomberg.github.io/memray/run.html#native-tracking - you'll need to use the --native option to memray run, and you'll need to generate the reports on the same machine the capture file was generated on.

zdyj3170101136 commented 10 months ago

Yes, see https://bloomberg.github.io/memray/run.html#native-tracking - you'll need to use the --native option to memray run, and you'll need to generate the reports on the same machine the capture file was generated on.

memray-flamegraph-benchmakr.py.13823.html.zip

here is my memory profiling.

i read a lot of image:

import os
import PIL
from PIL import Image

dir = "/home/centos/pillow-bench/Images_0/0"
onlyfiles = []

filedir = dir
files = [f for f in os.listdir(filedir) if os.path.isfile(os.path.join(filedir, f))]
filepaths = map( lambda x: os.path.join(filedir, x), files )
onlyfiles += list(filepaths)

s = 0
for i in range(len(onlyfiles)):
    fname = onlyfiles[i]
    image = PIL.Image.open(fname)
    # Do something
    image.tobytes("xbm", "rgb")
    if i % 10000 == 0:
        print('iteration ', i)

input("Press Enter to continue...")

i expect there have lots of memory allocation by pillow package, but there is not.