A while back we added tests to make sure we weren't leaking hiwire keys. As a special case of this, we also were testing that we weren't leaking JsProxies. In the future, I would like to add tests to show that we aren't leaking PyProxies either. Currently we leak quite a lot of them.

Before we actually add any tests to show that we aren't leaking proxies, I'd like to rework the model of the PyProxy lifetime. The planned changes should make it far easier to actually avoid these leaks while still using a reasonably natural coding style.

This change has no user-facing effect: the tracing is disabled by default and the API to enable it is private and always will be.
Add support for pyproxy allocation tracing. A while back we added tests to make sure we weren't leaking hiwire keys. As a special case of this, we also were testing that we weren't leaking JsProxies. In the future, I would like to add tests to show that we aren't leaking PyProxies either. Currently we leak quite a lot of them.

Before we actually add any tests to show that we aren't leaking proxies, I'd like to rework the model of the PyProxy lifetime. The planned changes should make it far easier to actually avoid these leaks while still using a reasonably natural coding style.

This change has no user-facing effect: the tracing is disabled by default and the API to enable it is private and always will be.
diff --git a/imageio/core/findlib.py b/imageio/core/findlib.py
--- a/imageio/core/findlib.py
+++ b/imageio/core/findlib.py
@@ -7,7 +7,6 @@
 
 import os
 import sys
-import ctypes
 
 
 LOCALDIR = os.path.abspath(os.path.dirname(__file__))
@@ -95,6 +94,7 @@ def load_lib(exact_lib_names, lib_names, lib_dirs=None):
 
     Returns ``(ctypes_library, library_path)``
     """
+    import ctypes
 
     # Checks
     assert isinstance(exact_lib_names, list)

diff --git a/imageio/plugins/__init__.py b/imageio/plugins/__init__.py
index 7e26683..971f83e 100644
--- a/imageio/plugins/__init__.py
+++ b/imageio/plugins/__init__.py
@@ -84,8 +84,8 @@ from . import tifffile
 from . import pillow
 from . import grab
 
-from . import freeimage
-from . import freeimagemulti
+# from . import freeimage
+# from . import freeimagemulti
 
 from . import ffmpeg
 

diff --git a/imageio/core/findlib.py b/imageio/core/findlib.py
--- a/imageio/core/findlib.py
+++ b/imageio/core/findlib.py
@@ -7,7 +7,6 @@
 
 import os
 import sys
-import ctypes
 
 
 LOCALDIR = os.path.abspath(os.path.dirname(__file__))
@@ -95,6 +94,7 @@ def load_lib(exact_lib_names, lib_names, lib_dirs=None):
 
     Returns ``(ctypes_library, library_path)``
     """
+    import ctypes
 
     # Checks
     assert isinstance(exact_lib_names, list)

diff --git a/imageio/plugins/__init__.py b/imageio/plugins/__init__.py
index 7e26683..971f83e 100644
--- a/imageio/plugins/__init__.py
+++ b/imageio/plugins/__init__.py
@@ -84,8 +84,8 @@ from . import tifffile
 from . import pillow
 from . import grab
 
-from . import freeimage
-from . import freeimagemulti
+# from . import freeimage
+# from . import freeimagemulti
 
 from . import ffmpeg
 
