I have multiple large rasters. Their 5 percentile and 95 percentile are needed to be calculated. After loading the rasters to the ArcMap, I am using the following codes - 


    import numpy
    import arcpy
    
    rasters = ["raster1.tif", "raster2.tif", "raster3.tif", "raster4.tif"]

    for i in rasters:
        array = arcpy.RasterToNumPyArray(i,nodata_to_value=10000000000)
        marray = numpy.ma.masked_values(array,10000000000)
        del array
        percentile5 = numpy.percentile(marray.compressed(),(5))
        percentile95 = numpy.percentile(marray.compressed(),(95))
        del marray
        print percentile5 , percentile95 

For the first two rasters, it provides the percentile values. For the third raster, it is showing memory errors.

I am using ArcMap 10.5 in desktop with 32 GB Ram. 

Is there any way to get rid of this memory issue?