Thankfully this was a lot easier than tracing hiwire keys. 

I located one actual leak: if an error is thrown during `to_js` it would forget to free `proxies`. Other than that, I fixed a few "dumb leaks" in `api.js` where we leak the methods like `eval_code` or `find_imports`. So the code was already in surprisingly good shape in this way.

It's still possible that we leak some Python objects somehow, but this is as good as we can do for systematic checks short of compiling Python itself with `TRACE_MALLOC`.
Eliminate pyproxy leaks. Thankfully this was a lot easier than tracing hiwire keys. 

I located one actual leak: if an error is thrown during `to_js` it would forget to free `proxies`. Other than that, I fixed a few "dumb leaks" in `api.js` where we leak the methods like `eval_code` or `find_imports`. So the code was already in surprisingly good shape in this way.

It's still possible that we leak some Python objects somehow, but this is as good as we can do for systematic checks short of compiling Python itself with `TRACE_MALLOC`.
This patch is integrated in scikit-image v0.18.0
diff --git a/skimage/restoration/_unwrap_2d.pyx b/skimage/restoration/_unwrap_2d.pyx
index ad0dfa2280..8e2d6ee3ae 100644
--- a/skimage/restoration/_unwrap_2d.pyx
+++ b/skimage/restoration/_unwrap_2d.pyx
@@ -3,13 +3,17 @@
 # cython: nonecheck=False
 # cython: wraparound=False
 
-cdef extern from *:
-    void unwrap2D(double* wrapped_image,
-                  double* unwrapped_image,
-                  unsigned char* input_mask,
-                  int image_width, int image_height,
-                  int wrap_around_x, int wrap_around_y,
-                  char use_seed, unsigned int seed) nogil
+
+cdef extern from "unwrap_2d_ljmu.h":
+    void unwrap2D(
+            double *wrapped_image,
+            double *UnwrappedImage,
+            unsigned char *input_mask,
+            int image_width, int image_height,
+            int wrap_around_x, int wrap_around_y,
+            char use_seed, unsigned int seed
+            ) nogil
+
 
 def unwrap_2d(double[:, ::1] image,
               unsigned char[:, ::1] mask,
diff --git a/skimage/restoration/_unwrap_3d.pyx b/skimage/restoration/_unwrap_3d.pyx
index eac50e70fb..2c9bbfbb1d 100644
--- a/skimage/restoration/_unwrap_3d.pyx
+++ b/skimage/restoration/_unwrap_3d.pyx
@@ -3,13 +3,18 @@
 # cython: nonecheck=False
 # cython: wraparound=False
 
-cdef extern from *:
-  void unwrap3D(double* wrapped_volume,
-                double* unwrapped_volume,
-                unsigned char* input_mask,
-                int image_width, int image_height, int volume_depth,
-                int wrap_around_x, int wrap_around_y, int wrap_around_z,
-                char use_seed, unsigned int seed) nogil
+
+cdef extern from "unwrap_3d_ljmu.h":
+    void unwrap3D(
+            double *wrapped_volume,
+            double *unwrapped_volume,
+            unsigned char *input_mask,
+            int volume_width, int volume_height, int volume_depth,
+            int wrap_around_x, int wrap_around_y, int wrap_around_z,
+            char use_seed, unsigned int seed
+            ) nogil
+
+
 
 def unwrap_3d(double[:, :, ::1] image,
               unsigned char[:, :, ::1] mask,
diff --git a/skimage/restoration/unwrap_2d_ljmu.c b/skimage/restoration/unwrap_2d_ljmu.c
index 690a8d7741..ac60a7d98e 100644
--- a/skimage/restoration/unwrap_2d_ljmu.c
+++ b/skimage/restoration/unwrap_2d_ljmu.c
@@ -39,6 +39,7 @@
 #define NOMASK 0
 #define MASK 1
 
+
 typedef struct {
   double mod;
   int x_connectivity;
diff --git a/skimage/restoration/unwrap_2d_ljmu.h b/skimage/restoration/unwrap_2d_ljmu.h
new file mode 100644
index 0000000000..9b26d808ff
--- /dev/null
+++ b/skimage/restoration/unwrap_2d_ljmu.h
@@ -0,0 +1,9 @@
+void unwrap2D(
+        double *wrapped_image,
+        double *UnwrappedImage,
+        unsigned char *input_mask,
+        int image_width, int image_height,
+        int wrap_around_x, int wrap_around_y,
+        char use_seed, unsigned int seed
+        );
+
diff --git a/skimage/restoration/unwrap_3d_ljmu.c b/skimage/restoration/unwrap_3d_ljmu.c
index fdd9847ae8..301414cb5e 100644
--- a/skimage/restoration/unwrap_3d_ljmu.c
+++ b/skimage/restoration/unwrap_3d_ljmu.c
@@ -40,6 +40,8 @@
 #define NOMASK 0
 #define MASK 1
 
+
+
 typedef struct {
   double mod;
   int x_connectivity;
diff --git a/skimage/restoration/unwrap_3d_ljmu.h b/skimage/restoration/unwrap_3d_ljmu.h
new file mode 100644
index 0000000000..8038639073
--- /dev/null
+++ b/skimage/restoration/unwrap_3d_ljmu.h
@@ -0,0 +1,9 @@
+void unwrap3D(
+        double *wrapped_volume,
+        double *unwrapped_volume,
+        unsigned char *input_mask,
+        int volume_width, int volume_height, int volume_depth,
+        int wrap_around_x, int wrap_around_y, int wrap_around_z,
+        char use_seed, unsigned int seed
+        );
+

This patch is integrated in scikit-image v0.18.0
diff --git a/skimage/restoration/_unwrap_2d.pyx b/skimage/restoration/_unwrap_2d.pyx
index ad0dfa2280..8e2d6ee3ae 100644
--- a/skimage/restoration/_unwrap_2d.pyx
+++ b/skimage/restoration/_unwrap_2d.pyx
@@ -3,13 +3,17 @@
 # cython: nonecheck=False
 # cython: wraparound=False
 
-cdef extern from *:
-    void unwrap2D(double* wrapped_image,
-                  double* unwrapped_image,
-                  unsigned char* input_mask,
-                  int image_width, int image_height,
-                  int wrap_around_x, int wrap_around_y,
-                  char use_seed, unsigned int seed) nogil
+
+cdef extern from "unwrap_2d_ljmu.h":
+    void unwrap2D(
+            double *wrapped_image,
+            double *UnwrappedImage,
+            unsigned char *input_mask,
+            int image_width, int image_height,
+            int wrap_around_x, int wrap_around_y,
+            char use_seed, unsigned int seed
+            ) nogil
+
 
 def unwrap_2d(double[:, ::1] image,
               unsigned char[:, ::1] mask,
diff --git a/skimage/restoration/_unwrap_3d.pyx b/skimage/restoration/_unwrap_3d.pyx
index eac50e70fb..2c9bbfbb1d 100644
--- a/skimage/restoration/_unwrap_3d.pyx
+++ b/skimage/restoration/_unwrap_3d.pyx
@@ -3,13 +3,18 @@
 # cython: nonecheck=False
 # cython: wraparound=False
 
-cdef extern from *:
-  void unwrap3D(double* wrapped_volume,
-                double* unwrapped_volume,
-                unsigned char* input_mask,
-                int image_width, int image_height, int volume_depth,
-                int wrap_around_x, int wrap_around_y, int wrap_around_z,
-                char use_seed, unsigned int seed) nogil
+
+cdef extern from "unwrap_3d_ljmu.h":
+    void unwrap3D(
+            double *wrapped_volume,
+            double *unwrapped_volume,
+            unsigned char *input_mask,
+            int volume_width, int volume_height, int volume_depth,
+            int wrap_around_x, int wrap_around_y, int wrap_around_z,
+            char use_seed, unsigned int seed
+            ) nogil
+
+
 
 def unwrap_3d(double[:, :, ::1] image,
               unsigned char[:, :, ::1] mask,
diff --git a/skimage/restoration/unwrap_2d_ljmu.c b/skimage/restoration/unwrap_2d_ljmu.c
index 690a8d7741..ac60a7d98e 100644
--- a/skimage/restoration/unwrap_2d_ljmu.c
+++ b/skimage/restoration/unwrap_2d_ljmu.c
@@ -39,6 +39,7 @@
 #define NOMASK 0
 #define MASK 1
 
+
 typedef struct {
   double mod;
   int x_connectivity;
diff --git a/skimage/restoration/unwrap_2d_ljmu.h b/skimage/restoration/unwrap_2d_ljmu.h
new file mode 100644
index 0000000000..9b26d808ff
--- /dev/null
+++ b/skimage/restoration/unwrap_2d_ljmu.h
@@ -0,0 +1,9 @@
+void unwrap2D(
+        double *wrapped_image,
+        double *UnwrappedImage,
+        unsigned char *input_mask,
+        int image_width, int image_height,
+        int wrap_around_x, int wrap_around_y,
+        char use_seed, unsigned int seed
+        );
+
diff --git a/skimage/restoration/unwrap_3d_ljmu.c b/skimage/restoration/unwrap_3d_ljmu.c
index fdd9847ae8..301414cb5e 100644
--- a/skimage/restoration/unwrap_3d_ljmu.c
+++ b/skimage/restoration/unwrap_3d_ljmu.c
@@ -40,6 +40,8 @@
 #define NOMASK 0
 #define MASK 1
 
+
+
 typedef struct {
   double mod;
   int x_connectivity;
diff --git a/skimage/restoration/unwrap_3d_ljmu.h b/skimage/restoration/unwrap_3d_ljmu.h
new file mode 100644
index 0000000000..8038639073
--- /dev/null
+++ b/skimage/restoration/unwrap_3d_ljmu.h
@@ -0,0 +1,9 @@
+void unwrap3D(
+        double *wrapped_volume,
+        double *unwrapped_volume,
+        unsigned char *input_mask,
+        int volume_width, int volume_height, int volume_depth,
+        int wrap_around_x, int wrap_around_y, int wrap_around_z,
+        char use_seed, unsigned int seed
+        );
+
