Commit d4a5ed6
authored
Fix a memory leak in the Operator base class (#1632)
* Fix a memory leak in the Operator base class
References to operator *class* definitions were cached in the argument cache of
`_dispatch_call_args` function, hence GC couldn't collect them. Normally that's not
an issue, as class definitions don't consume much memory. However, a typical
pattern of defining adjoint operators in ODL is using nested classes with
references back to their encapsulating *objects*. Depending on the Operator, it
may cause considerable memory leaks. For example, `RayTransform` objects hold
references to space and geometry objects, preventing them from being reaped by
GC and leading to considerable memory leaks.
The fix I've implemented is moving away from an argument cache in favor of caching
the returned values on the class itself. This ensures no class object references are
held permanently in the cache_arguments() decorator.1 parent 139e796 commit d4a5ed6
1 file changed
+15
-16
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
21 | 20 | | |
22 | 21 | | |
23 | 22 | | |
| |||
122 | 121 | | |
123 | 122 | | |
124 | 123 | | |
125 | | - | |
126 | 124 | | |
127 | 125 | | |
128 | 126 | | |
| |||
420 | 418 | | |
421 | 419 | | |
422 | 420 | | |
423 | | - | |
424 | | - | |
425 | | - | |
426 | | - | |
427 | | - | |
428 | | - | |
429 | | - | |
430 | | - | |
431 | | - | |
432 | | - | |
433 | | - | |
434 | | - | |
435 | | - | |
436 | | - | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
437 | 436 | | |
438 | 437 | | |
439 | 438 | | |
| |||
0 commit comments