diff --git a/gdal/swig/python/scripts/gdal2tiles.py b/gdal/swig/python/scripts/gdal2tiles.py index f49d8ccade59..b9dc220b2baa 100755 --- a/gdal/swig/python/scripts/gdal2tiles.py +++ b/gdal/swig/python/scripts/gdal2tiles.py @@ -2883,8 +2883,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)) pool = Pool(processes=nb_processes)