puppetlabs / trapperkeeper

A services framework for Clojure / JVM applications.
https://tickets.puppetlabs.com/browse/TK
Apache License 2.0
587 stars 74 forks source link

Add option to disable the accumulation of tk-apps in a global atom #291

Open vemv opened 3 years ago

vemv commented 3 years ago

Use Case

In a dev environment (but certainly not in production), the register-sighup-handler defn is largely unnecessary. Because of that, the global tk-apps atom also becomes unnecesary, particularly if one has a different means of accessing a global app object (which is very usual under a Reloaded workflow).

By accumulating apps in this atom, one creates hard memory references that can plausibly create a memory leak.

Describe the Solution You Would Like

Inrtroduce a java system property which elides this call: https://github.com/puppetlabs/trapperkeeper/blob/c943510c08acde6b1e3c2b55b450fef325734022/src/puppetlabs/trapperkeeper/core.clj#L158

Said property would typically enabled only in dev envs.

Describe Alternatives You've Considered

One could keep the functionality but changing it to use WeakReferences instead. Seems a needless source of complexity though.