Repository navigation
Share Windows GlobalMemory/VirtualMemory logic across JNA and FFM - #3453
Conversation
Windows was the last platform whose memory twins still carried full logic in both backends; every other platform already has a base + thin native-only twins. Bring Windows into line. WindowsGlobalMemory (existing base, previously only the memory-type tables) now holds the memoized available/total/page-size suppliers, the virtual-memory supplier, and the WMI physical-memory assembly loop, with protected abstract hooks for the native queries (readPerfInfo, createVirtualMemory, isWindows10OrGreater, queryPhysicalMemory[Win8]). WindowsVirtualMemory is new (VirtualMemory had no shared base): it holds the parent-global reference, memoized suppliers, and the six page-size-scaled getters, with hooks querySwapUsed / querySwapTotalVirtMaxVirtUsed / queryPageSwaps. The JNA and FFM twins shrink to just those native hooks (GlobalMemory 119/128 -> 67/79 lines, VirtualMemory 106/111 -> 65/71). No behavior change; the hoisted logic is identical to what both twins previously duplicated.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (6)
📜 Recent review details⏰ Context from checks skipped due to timeout. (16)
🧰 Additional context used🧠 Learnings (3)📚 Learning: 2026-04-12T19:22:09.716ZApplied to files:
📚 Learning: 2026-07-06T19:25:59.225ZApplied to files:
📚 Learning: 2026-04-06T04:45:47.644ZApplied to files:
🔇 Additional comments (6)
📝 WalkthroughWalkthroughWindows memory handling was centralized into shared global and virtual memory base classes. JNA and FFM implementations now provide protected hooks for native metrics, WMI queries, OS detection, and backend object creation. ChangesWindows memory abstraction
Estimated code review effort: 3 (Moderate) | ~25 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #3453 +/- ##
============================================
- Coverage 74.59% 74.57% -0.02%
Complexity 76 76
============================================
Files 583 584 +1
Lines 21961 21923 -38
Branches 3682 3679 -3
============================================
- Hits 16381 16350 -31
+ Misses 3539 3534 -5
+ Partials 2041 2039 -2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Summary
Part of the cross-OS consistency/dedup audit (Item 5, memory). Every platform's
GlobalMemory/VirtualMemoryclasses already follow the shared-base + thin-native-twin shape (done during the FFM ports) except Windows, whose JNA and FFM twins still carried the full logic in both backends. This brings Windows into line.Changes
GlobalMemory —
WindowsGlobalMemory(existing base, previously just the memory-type lookup tables) now holds:available/total/pageSizesuppliers + gettersgetVirtualMemory()getPhysicalMemory()WMI bank-assembly loopwith
protected abstracthooks for the native pieces:readPerfInfo(),createVirtualMemory(),isWindows10OrGreater(),queryPhysicalMemory(),queryPhysicalMemoryWin8().VirtualMemory —
VirtualMemoryhad no shared base, soWindowsVirtualMemoryis new: it holds the parent-global reference, the memoizedused/totalVmaxVused/swapInOutsuppliers, and the six page-size-scaled getters, with hooksquerySwapUsed(),querySwapTotalVirtMaxVirtUsed(),queryPageSwaps().The JNA and FFM twins shrink to just those native hooks:
~182 lines of duplicated twin logic eliminated. (Raw net LOC is roughly flat because
WindowsVirtualMemoryis a new file andWindowsGlobalMemoryabsorbs the loop that was duplicated in both twins — the win is single-source-of-truth / reduced duplication, matching every other platform.)Behavior
No user-facing change — the hoisted logic is identical to what both twins previously duplicated; only the native queries remain per-backend.
Testing
install: BUILD SUCCESS, 0 tests failed (compiles the Windows JNA + FFM classes on all modules);WindowsGlobalMemoryTestpassesSummary by CodeRabbit