Memory leak in snappy/jpy when passing/returning arrays


It seems snappy (or jpy) is unable to free the memory corresponding to arrays being passed to or returned from Java. Please find below a minimal example, which quickly fills up the memory until the JVM crashes.

Python code:

import snappy                                                                                                                                              
import numpy as np                                                                                                                                         

SlcImage = snappy.jpy.get_type('org.jlinda.core.SLCImage')                                                                                                 
AbstractMetadata = snappy.jpy.get_type(                                                                                                                    
product = snappy.ProductIO.readProduct('product.dim')                                                                                                           
master_root = AbstractMetadata.getAbstractedMetadata(product)                                                                                              
master_meta = SlcImage(master_root, product)
for idx in range(1000):
    temp = np.asarray(master_meta.test(np.ones((1, int(3e7)))))

Java code:

public double[] test(double[] pixel) {
    double[] tr = new double[pixel.length];
    for (int i = 0; i < pixel.length; i++) {
            tr[i] = 30.0 + pixel[i];
    return tr;

Should this be freed explicitly?


I managed to resolve this issue. Please see related closed issue on GitHub.