Mitigate strongly memory leaks related to repository classes
See heptapod#466 (closed) and changeset descriptions for more context.
Here are some high-level results, based on partial yet substantial functional test runs (test_merge_requests.py from heptapod-tests@649cf23be452 if anyone want to reproduce the experiment).
The HGitaly server is configured as in the HDK default, hence forks a single worker and listens on a Unix Domain socket.
After startup, resident size (RSS) is a bit less than 35MB.
Without the changes in this MR, RSS climbs after the test run to about 180MB. With these changes, it climbs to 52MB.
There is still a leak (I can see the RSS keeping on growing), but it went from 145MB to 17MB.