Coder Social home page Coder Social logo

Comments (2)

sgillies avatar sgillies commented on June 12, 2024

@aloi214 Thanks for the report! I have a few questions:

  • Is fastapi required to produce the increasing memory? What do you see if you just loop over create_mask() without accumulating results?
  • Are you aware that GDAL has a raster block cache? Sometimes this appears to be a leak to users. What do you see if you run your program with the environment variable set to GDAL_CACHEMAX=0?

from rasterio.

aloi214 avatar aloi214 commented on June 12, 2024

@sgillies Thanks for replying. As I know, usually the occupied memory after finishing each request should keep same after first request. And I run more test:

  1. loop over create_mask() without append result into a list.
  2. limit GDAL_CACHEMAX as
def create_mask(polyline):
    polyline = np.array(polyline)
    origin = polyline.min(axis=0)
    site_shape = (polyline.max(axis=0) - polyline.min(axis=0))[::-1].astype(int)
    shapely_geo = sg.Polygon(polyline-origin)
    with rasterio.Env(GDAL_CACHEMAX=0, CPL_VSIL_CURL_CACHE_SIZE=0, VSI_CACHE=False, VSI_CACHE_SIZE=0, aws_unsigned=True) as env:
        control_mask = features.geometry_mask([shapely_geo], out_shape=site_shape, transform=transform.IDENTITY, invert=False)
    return control_mask
  1. Excute export GDAL_CACHEMAX=0 in command line to limit GDAL_CACHEMAX.

But the memory are keeping increase in all those cases. I'm not sure if I limit the GDAL_CACHEMAX successfully.

from rasterio.

Related Issues (20)

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.