diff --git a/gdal/swig/python/scripts/gdal2tiles.py b/gdal/swig/python/scripts/gdal2tiles.py index dd169c3b5e8f..106d4c8e8352 100755 --- a/gdal/swig/python/scripts/gdal2tiles.py +++ b/gdal/swig/python/scripts/gdal2tiles.py @@ -2867,8 +2867,8 @@ def single_threaded_tiling(input_file, output_folder, options): def multi_threaded_tiling(input_file, output_folder, options): nb_processes = options.nb_processes or 1 - # Make sure that all processes do not consume more than GDAL_CACHEMAX - os.environ['GDAL_CACHEMAX'] = '%d' % int(gdal.GetCacheMax() / nb_processes) + # Make sure that all processes do not consume more than `gdal.GetCacheMax()` + os.environ['GDAL_CACHEMAX'] = '%d' % max(1, int(gdal.GetCacheMax() / 1024 / 1024 / nb_processes)) (conf_receiver, conf_sender) = Pipe(False)