mmustafasenoglu opened a new pull request, #6732:
URL: https://github.com/apache/jmeter/pull/6732

   ## Summary
   
   `CacheManager.clearCache()` creates a new `InheritableThreadLocal` instance 
on every call without calling `.remove()` on the previous one, causing a 
progressive memory leak that grows with `iteration_count × thread_count` when 
"Clear cache each iteration" is enabled.
   
   The existing TODO in the code already acknowledged this:
   
   ```java
   // TODO: avoid re-creating the thread local every time, reset its contents 
instead
   ```
   
   ## Fix
   
   - Initialize `threadCache` once at field declaration
   - Replace `clearCache()` body with `threadCache.remove()` instead of 
creating a new instance
   - The next `.get()` call lazily creates a fresh cache via `initialValue()`
   - Added `@SuppressWarnings("ThreadLocalUsage")` since 
`InheritableThreadLocal` is intentionally used for per-thread caching
   
   ## Testing
   
   All 80 CacheManager tests pass (0 failed, 1 skipped):
   
   ```
   TestCacheManagerThreadIteration:      5/5  ✅
   TestCacheManagerHC4:                 50/50 ✅
   TestCacheManagerUrlConnection:       25/25 ✅
   ```
   
   Fixes #6730
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to