| 27 | let debouncedGC: Map<number, () => void>; |
| 28 | |
| 29 | export function queueGC(delay = 900, useThrottle?: boolean) { |
| 30 | /** |
| 31 | * developers can use different queueGC settings to optimize their own apps |
| 32 | * each setting is stored in a Map to reuse each time app calls it |
| 33 | */ |
| 34 | if (useThrottle) { |
| 35 | if (!throttledGC) { |
| 36 | throttledGC = new Map(); |
| 37 | } |
| 38 | if (!throttledGC.get(delay)) { |
| 39 | throttledGC.set( |
| 40 | delay, |
| 41 | throttle(() => GC(), delay), |
| 42 | ); |
| 43 | } |
| 44 | throttledGC.get(delay)(); |
| 45 | } else { |
| 46 | if (!debouncedGC) { |
| 47 | debouncedGC = new Map(); |
| 48 | } |
| 49 | if (!debouncedGC.get(delay)) { |
| 50 | debouncedGC.set( |
| 51 | delay, |
| 52 | debounce(() => GC(), delay), |
| 53 | ); |
| 54 | } |
| 55 | debouncedGC.get(delay)(); |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | export function releaseNativeObject(object: java.lang.Object) { |
| 60 | __releaseNativeCounterpart(object); |