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`.
commit d6740caa7400105a578ace74f8c25bbb3434178c
Author: Roman Yurchak <rth.yurchak@pm.me>
Date:   Wed Oct 10 14:47:12 2018 +0200

    Disable scipy.stats.mvn

diff --git a/scipy/stats/kde.py b/scipy/stats/kde.py
index 7c702a038..8b0ab0254 100644
--- a/scipy/stats/kde.py
+++ b/scipy/stats/kde.py
@@ -32,7 +32,10 @@ import numpy as np
 from numpy.random import randint, multivariate_normal
 
 # Local imports.
-from . import mvn
+try:
+    from . import mvn
+except ImportError:
+    mvn = None
 
 
 __all__ = ['gaussian_kde']
diff --git a/scipy/stats/setup.py b/scipy/stats/setup.py
index f1a02df4e..7366ec12d 100755
--- a/scipy/stats/setup.py
+++ b/scipy/stats/setup.py
@@ -32,9 +32,9 @@ def configuration(parent_package='',top_path=None):
     )
 
     # add mvn module
-    config.add_extension('mvn',
-        sources=['mvn.pyf','mvndst.f'],
-    )
+    #config.add_extension('mvn',
+    #    sources=['mvn.pyf','mvndst.f'],
+    #)
 
     return config
 

commit d6740caa7400105a578ace74f8c25bbb3434178c
Author: Roman Yurchak <rth.yurchak@pm.me>
Date:   Wed Oct 10 14:47:12 2018 +0200

    Disable scipy.stats.mvn

diff --git a/scipy/stats/kde.py b/scipy/stats/kde.py
index 7c702a038..8b0ab0254 100644
--- a/scipy/stats/kde.py
+++ b/scipy/stats/kde.py
@@ -32,7 +32,10 @@ import numpy as np
 from numpy.random import randint, multivariate_normal
 
 # Local imports.
-from . import mvn
+try:
+    from . import mvn
+except ImportError:
+    mvn = None
 
 
 __all__ = ['gaussian_kde']
diff --git a/scipy/stats/setup.py b/scipy/stats/setup.py
index f1a02df4e..7366ec12d 100755
--- a/scipy/stats/setup.py
+++ b/scipy/stats/setup.py
@@ -32,9 +32,9 @@ def configuration(parent_package='',top_path=None):
     )
 
     # add mvn module
-    config.add_extension('mvn',
-        sources=['mvn.pyf','mvndst.f'],
-    )
+    #config.add_extension('mvn',
+    #    sources=['mvn.pyf','mvndst.f'],
+    #)
 
     return config
 
