Improvement: githubAnalyzer cache grows unbounded (memory leak on 512MB plan)
File: server/utils/githubAnalyzer.js:36
Problem
The in-memory cache githubCache is a Map that grows without bound:
const githubCache = new Map();
Entries are only evicted when accessed and found expired (lazy eviction in getCached). If many unique usernames are analyzed and never re-accessed, the cache grows indefinitely.
Each cached entry stores up to 30 simplified repo objects (~2-5KB per username). After 1000 unique usernames: ~5MB. After 10,000: ~50MB.
Impact on 512MB Render plan
With the lazy-load optimization from Phase 6 (server starts at ~113MB), a 50MB cache leak would bring total to ~163MB — still within limits, but concerning for long-running instances.
Fix
- Simple: Add a max size check in
setCached:
function setCached(key, data) {
if (githubCache.size > 500) {
// Evict oldest entries
const firstKey = githubCache.keys().next().value;
githubCache.delete(firstKey);
}
githubCache.set(key, { data, timestamp: Date.now() });
}
-
Better: Use an LRU cache library like lru-cache with a size limit and TTL.
-
Best: Move cache to Redis (if available) or MongoDB for persistence across restarts.
Severity
Low-Medium — Slow leak. Won't cause immediate issues but could accumulate over weeks of uptime.
Phase
Introduced in Phase 3 (PR #28, merged).
Improvement: githubAnalyzer cache grows unbounded (memory leak on 512MB plan)
File:
server/utils/githubAnalyzer.js:36Problem
The in-memory cache
githubCacheis aMapthat grows without bound:Entries are only evicted when accessed and found expired (lazy eviction in
getCached). If many unique usernames are analyzed and never re-accessed, the cache grows indefinitely.Each cached entry stores up to 30 simplified repo objects (~2-5KB per username). After 1000 unique usernames: ~5MB. After 10,000: ~50MB.
Impact on 512MB Render plan
With the lazy-load optimization from Phase 6 (server starts at ~113MB), a 50MB cache leak would bring total to ~163MB — still within limits, but concerning for long-running instances.
Fix
setCached:Better: Use an LRU cache library like
lru-cachewith a size limit and TTL.Best: Move cache to Redis (if available) or MongoDB for persistence across restarts.
Severity
Low-Medium — Slow leak. Won't cause immediate issues but could accumulate over weeks of uptime.
Phase
Introduced in Phase 3 (PR #28, merged).