You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Dear users, I'm trying to debug some possible memory leak issue with rio-tiler (this subject has been brought many time over the rasterio repo and it seems that is there is a leak it might be at users application level, e.g rio-tiler). Before raising a new issue in rasterio I would like to be sure that's it's not in rio-tiler 😅
Where ?
rio_tiler.reader.read
rio_tiler.models.ImageData
rio_tiler.tasks.create_tasks
rio_tiler.mosaic.*
I'm out of ideas/clues of what is going on so if someone wants to help, it will be really appreciated 🙏
python scripts: memory_mosaic.py
fromrio_tiler.ioimportReaderfromrio_tiler.mosaicimportmosaic_readerfromrandomimportsampleimportmorecantileimportrasteriofromrio_tiler.modelsimportImageDatafrommemory_profilerimportprofilefromrio_tiler.mosaic.methodsimportLowestMethodassets= [
"tests/fixtures/mosaic_value_1.tif",
"tests/fixtures/mosaic_value_2.tif",
"tests/fixtures/mosaic_value_1.tif",
"tests/fixtures/mosaic_value_2.tif",
]
tilematrixset=morecantile.tms.get("WebMercatorQuad")
w, s, e, n= [-76, 44.93, -71.33, 47.1]
minzoom=7maxzoom=9extrema= {}
forzoominrange(minzoom, maxzoom+1):
ul_tile=tilematrixset.tile(w, n, zoom)
lr_tile=tilematrixset.tile(e, s, zoom)
extrema[zoom] = {
"x": {"min": ul_tile.x, "max": lr_tile.x+1},
"y": {"min": ul_tile.y, "max": lr_tile.y+1},
}
def_reader(path: str, x: int, y: int, z: int, **kwargs):
withReader(path) assrc:
returnsrc.tile(x, y, z, **kwargs)
@profile()defmosaic(x, y, z):
# while True:im, _=mosaic_reader(
assets,
_reader,
x,
y,
z,
threads=1,
tilesize=4000,
pixel_selection=LowestMethod,
)
im=NonereturnTrue@profile()defimage_from_list(x, y, z):
imgs= []
forassetinassets:
try:
im=_reader(asset, x, y, z, tilesize=4000)
imgs.append(im)
except:
passimg=ImageData.create_from_list(imgs)
imgs=Noneimg=NonereturnTrue@profile()defimages(x, y, z):
forassetinassets:
try:
im=_reader(asset, x, y, z, tilesize=4000)
im=Noneexcept:
passreturnTrue@profile()defimage(x, y, z):
withReader(assets[0]) assrc:
im=src.tile(x, y, z, tilesize=4000)
im=NonereturnTrueif__name__=='__main__':
z=sample(range(minzoom, maxzoom+1), 1)[0]
x=sample(range(extrema[z]["x"]["min"], extrema[z]["x"]["max"]), 1)[0]
y=sample(range(extrema[z]["y"]["min"], extrema[z]["y"]["max"]), 1)[0]
_=image(x, y, z)
_=images(x, y, z)
_=mosaic(x, y, z)
_=image_from_list(x, y, z)
We decided to see if Valgrind could provide something more useful. @chuckwondo ran Scalene and it was showing that the memory usage is almost entirely outside python itself.
Dear users, I'm trying to debug some possible memory leak issue with rio-tiler (this subject has been brought many time over the rasterio repo and it seems that is there is a leak it might be at users application level, e.g rio-tiler). Before raising a new issue in rasterio I would like to be sure that's it's not in rio-tiler 😅
Where ?
rio_tiler.reader.read
rio_tiler.models.ImageData
rio_tiler.tasks.create_tasks
rio_tiler.mosaic.*
I'm out of ideas/clues of what is going on so if someone wants to help, it will be really appreciated 🙏
python scripts:
memory_mosaic.py
results
The issue was reported by a titiler-pgstac application user, resulting in memory increase like 👇
The text was updated successfully, but these errors were encountered: