Repository navigation
Separate RSS from the private/footprint memory shown by graphical system monitors - #3082
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdd explicit resident vs. private resident memory APIs ( Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant OS as OperatingSystem
participant Proc as OSProcess
participant Native as Native/Platform
Client->>OS: request process list / sort by footprint
OS->>Proc: getPrivateResidentMemory()
alt platform provides private value
Proc-->>OS: privateResidentMemory (private working set / footprint)
else fallback to resident
Proc->>Proc: getResidentMemory()
Proc-->>OS: residentMemory (RSS)
end
alt macOS FFM path
Proc->>Native: read ri_phys_footprint (RUSAGE_INFO_V2)
Native-->>Proc: ri_phys_footprint or RSS fallback
Proc-->>OS: memoryFootprint
end
OS-->>Client: return sorted process list
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 #3082 +/- ##
==========================================
+ Coverage 84.58% 85.30% +0.72%
==========================================
Files 33 33
Lines 1466 1470 +4
Branches 216 216
==========================================
+ Hits 1240 1254 +14
+ Misses 131 118 -13
- Partials 95 98 +3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@oshi-core-java25/src/main/java/oshi/software/os/mac/MacOSProcessFFM.java`:
- Line 170: The field declaration "private lgon memoryFootprint;" uses an
invalid type token "lgon"; update the type to the correct Java primitive "long"
for the field "memoryFootprint" in the MacOSProcessFFM class so it reads
"private long memoryFootprint;" and rebuild to ensure compilation succeeds.
ℹ️ Review info
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
oshi-core-java25/src/main/java/oshi/software/os/mac/MacOSProcessFFM.java
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: Codacy Static Code Analysis
- GitHub Check: Test JDK 25, macos-latest
- GitHub Check: Analyze (java)
🔇 Additional comments (1)
oshi-core-java25/src/main/java/oshi/software/os/mac/MacOSProcessFFM.java (1)
531-532: Memory footprint fallback/override flow looks correct.Using RSS as default (Line 531-Line 532) and overriding with
ri_phys_footprintwhen available (Line 557), then exposing viagetMemoryFootprint()(Line 354-Line 357), is a good compatibility pattern.Also applies to: 552-558, 354-357
|
Thanks for this PR! Code-wise, it's ready to merge, but I want to discuss what we currently display and how we name it. I changed the Javadoc for your new method to describe what it actually measures (footprint) rather than what you describe (the OS display). However, on Windows, we already display this "footprint" value (the Private Bytes / Working Set - Private value), rather than just Working Set Size (WSS) which is the closer analog to RSS. Current end users probably already use the existing RSS method to recreate "Task Manager" displays (just look at the oshi-demo project) so we can't really change that to be more accurate on macOS without breaking expectations, and I expect users of We also should consider the true Linux footprint, possibly Proportional Set Size ( Here's the landscape:
So we have an inconsistency today: Windows users already get the "footprint" style value from I think the right path forward is:
This gives users two clearly distinct methods with consistent cross-platform semantics, and the names actually describe what they return. Plus they have a common entry point for those who want to match their UI displays (which may differ from Open Question: On Linux, PSS is the best "footprint" analog but requires reading Happy to merge this PR now and address these questions in a follow-on PR, or if you want to do the redesign in this PR we can handle that as well. Let me know what you think. |
|
Hi @dbwiddis, I did some research in Gnome System Monitor source and get this:
What do you think? |
Looks pretty accurate to me! Is that "resident" - "shared"? (Edit: yes it is, from gnome source code |
|
Summarizing:
|
|
Proposed New Method Names/Javadoc description:
OS implementations:
|
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (2)
oshi-core/src/test/java/oshi/software/os/OperatingSystemTest.java (1)
129-132: Add the deprecated-accessor compatibility assertion here.These assertions cover the new APIs, but the fragile part of this PR is the old
getResidentSetSize()contract: Windows should still map it to private resident memory, while other platforms should keep delegating to resident memory. A small assertion here would catch regressions in that compatibility layer.🧪 Suggested test addition
assertThat("Current running process resident set size should be 0 or higher", proc.getResidentMemory(), is(greaterThanOrEqualTo(0L))); assertThat("Current running process private resident memory size should be 0 or higher", proc.getPrivateResidentMemory(), is(greaterThanOrEqualTo(0L))); + if (Platform.isWindows()) { + assertThat("Deprecated RSS accessor should preserve Windows private-working-set semantics", + proc.getResidentSetSize(), is(proc.getPrivateResidentMemory())); + } else { + assertThat("Deprecated RSS accessor should delegate to resident memory on non-Windows platforms", + proc.getResidentSetSize(), is(proc.getResidentMemory())); + }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@oshi-core/src/test/java/oshi/software/os/OperatingSystemTest.java` around lines 129 - 132, Add a compatibility assertion for the deprecated getResidentSetSize() to ensure Windows still maps it to private resident memory while other OSes map it to resident memory: after the existing assertions on proc.getResidentMemory() and proc.getPrivateResidentMemory(), detect Windows (e.g., System.getProperty("os.name").toLowerCase().contains("win")) and assert proc.getResidentSetSize() == proc.getPrivateResidentMemory() on Windows, otherwise assert proc.getResidentSetSize() == proc.getResidentMemory(); reference proc, getResidentSetSize(), getResidentMemory(), and getPrivateResidentMemory() when adding the assertion in OperatingSystemTest.oshi-core/src/main/java/oshi/driver/windows/registry/ProcessPerformanceData.java (1)
118-118: Rename the first working-set list to matchPRIVATEBYTES.Now that this path carries both private and total working set, the current locals are easy to misread: the first constructor argument still comes from
PRIVATEBYTES, but its name looks like the total working set. Renaming it toprivateWorkingSetSizeListwould make the mapping much safer to maintain.♻️ Suggested cleanup
- List<Long> workingSetSizeList = valueMap.get(ProcessPerformanceProperty.PRIVATEBYTES); + List<Long> privateWorkingSetSizeList = valueMap.get(ProcessPerformanceProperty.PRIVATEBYTES); List<Long> workingSetList = valueMap.get(ProcessPerformanceProperty.WORKINGSETBYTES); @@ processMap.put(pid, new PerfCounterBlock(instances.get(inst), ppidList.get(inst).intValue(), - priorityList.get(inst).intValue(), workingSetSizeList.get(inst), + priorityList.get(inst).intValue(), privateWorkingSetSizeList.get(inst), workingSetList.get(inst), ctime, upTime, ioReadList.get(inst), ioWriteList.get(inst), pageFaultsList.get(inst).intValue()));Also applies to: 137-140
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@oshi-core/src/main/java/oshi/driver/windows/registry/ProcessPerformanceData.java` at line 118, Rename the local variable workingSetList (from ProcessPerformanceData.java where it's assigned from ProcessPerformanceProperty.PRIVATEBYTES) to privateWorkingSetSizeList and update all its subsequent references (including the constructor call arguments around lines 137-140) so it is not confused with the total working set list obtained from ProcessPerformanceProperty.WORKINGSETBYTES; ensure the renamed identifier is used consistently where the PRIVATEBYTES-sourced list is passed to the ProcessPerformanceData constructor and any other usages in this scope.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@oshi-core/src/main/java/oshi/software/os/OSProcess.java`:
- Around line 181-222: OSProcess must remain source-compatible: make
getResidentSetSize() the abstract contract and convert getResidentMemory() and
getPrivateResidentMemory() to default implementations delegating to it;
specifically, remove the new abstract getResidentMemory() and instead add a
default getResidentMemory() that returns getResidentSetSize(), keep
getPrivateResidentMemory() as a default returning getResidentMemory(), and
preserve the `@Deprecated` annotation on getResidentSetSize() so existing
implementations compile unchanged while callers can migrate to the new names.
In `@oshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcess.java`:
- Around line 207-215: The override of getResidentSetSize() in WindowsOSProcess
currently lacks the `@Deprecated` annotation, so callers typed as WindowsOSProcess
won’t get deprecation warnings; add the `@Deprecated` annotation to the
WindowsOSProcess.getResidentSetSize() method (which delegates to
getPrivateResidentMemory()) to match the parent interface and preserve the
deprecation signal.
---
Nitpick comments:
In
`@oshi-core/src/main/java/oshi/driver/windows/registry/ProcessPerformanceData.java`:
- Line 118: Rename the local variable workingSetList (from
ProcessPerformanceData.java where it's assigned from
ProcessPerformanceProperty.PRIVATEBYTES) to privateWorkingSetSizeList and update
all its subsequent references (including the constructor call arguments around
lines 137-140) so it is not confused with the total working set list obtained
from ProcessPerformanceProperty.WORKINGSETBYTES; ensure the renamed identifier
is used consistently where the PRIVATEBYTES-sourced list is passed to the
ProcessPerformanceData constructor and any other usages in this scope.
In `@oshi-core/src/test/java/oshi/software/os/OperatingSystemTest.java`:
- Around line 129-132: Add a compatibility assertion for the deprecated
getResidentSetSize() to ensure Windows still maps it to private resident memory
while other OSes map it to resident memory: after the existing assertions on
proc.getResidentMemory() and proc.getPrivateResidentMemory(), detect Windows
(e.g., System.getProperty("os.name").toLowerCase().contains("win")) and assert
proc.getResidentSetSize() == proc.getPrivateResidentMemory() on Windows,
otherwise assert proc.getResidentSetSize() == proc.getResidentMemory();
reference proc, getResidentSetSize(), getResidentMemory(), and
getPrivateResidentMemory() when adding the assertion in OperatingSystemTest.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 073b1e8e-8f01-42d3-83cd-d0078fdada3a
📒 Files selected for processing (13)
oshi-core-java25/src/main/java/oshi/software/os/mac/MacOSProcessFFM.javaoshi-core/src/main/java/oshi/driver/windows/perfmon/ProcessInformation.javaoshi-core/src/main/java/oshi/driver/windows/registry/ProcessPerformanceData.javaoshi-core/src/main/java/oshi/software/os/OSProcess.javaoshi-core/src/main/java/oshi/software/os/OperatingSystem.javaoshi-core/src/main/java/oshi/software/os/linux/LinuxOSProcess.javaoshi-core/src/main/java/oshi/software/os/mac/MacOSProcess.javaoshi-core/src/main/java/oshi/software/os/unix/aix/AixOSProcess.javaoshi-core/src/main/java/oshi/software/os/unix/freebsd/FreeBsdOSProcess.javaoshi-core/src/main/java/oshi/software/os/unix/openbsd/OpenBsdOSProcess.javaoshi-core/src/main/java/oshi/software/os/unix/solaris/SolarisOSProcess.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcess.javaoshi-core/src/test/java/oshi/software/os/OperatingSystemTest.java
🚧 Files skipped from review as they are similar to previous changes (1)
- oshi-core-java25/src/main/java/oshi/software/os/mac/MacOSProcessFFM.java
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
- GitHub Check: Codacy Static Code Analysis
- GitHub Check: Analyze (java)
- GitHub Check: Test JDK 25, macos-latest
- GitHub Check: Test JDK 21, macos-latest
6749baa to
bf36ecd
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@oshi-core/src/main/java/oshi/software/os/linux/LinuxOSProcess.java`:
- Around line 390-401: The fallback branch in LinuxOSProcess (where
statmFields.length <= 2) sets residentSetSize but leaves privateResidentMemory
unchanged; update that branch to initialize privateResidentMemory as the
conservative fallback equal to residentSetSize (i.e., set privateResidentMemory
= residentSetSize) so callers get an upper-bound value when /proc/[pid]/statm
lacks shared-page info; adjust the block that reads ProcPidStat.RSS and computes
residentSetSize to also assign privateResidentMemory accordingly.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 99352cb0-7da7-4eb9-874a-5aaf1bc817c5
📒 Files selected for processing (6)
oshi-core/src/main/java/oshi/driver/windows/perfmon/ProcessInformation.javaoshi-core/src/main/java/oshi/driver/windows/registry/ProcessPerformanceData.javaoshi-core/src/main/java/oshi/software/os/linux/LinuxOSProcess.javaoshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcess.javaoshi-core/src/test/java/oshi/SystemInfoTest.javaoshi-core/src/test/java/oshi/software/os/OperatingSystemTest.java
🚧 Files skipped from review as they are similar to previous changes (2)
- oshi-core/src/main/java/oshi/software/os/windows/WindowsOSProcess.java
- oshi-core/src/main/java/oshi/driver/windows/perfmon/ProcessInformation.java
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
- GitHub Check: Codacy Static Code Analysis
- GitHub Check: Analyze (java)
- GitHub Check: Test JDK 25, macos-latest
- GitHub Check: Test JDK 25, windows-latest
🔇 Additional comments (8)
oshi-core/src/main/java/oshi/software/os/linux/LinuxOSProcess.java (2)
87-87: LGTM!New field added to track private resident memory separately from total resident set size.
212-220: LGTM!The new memory accessors are correctly implemented.
getResidentMemory()returns the total RSS, whilegetPrivateResidentMemory()returns the private (non-shared) portion. This aligns with the PR objectives to expose both metrics with clear, distinct names.oshi-core/src/test/java/oshi/software/os/OperatingSystemTest.java (1)
129-139: LGTM!The test assertions correctly validate the new memory APIs and verify the backward-compatible behavior of the deprecated
getResidentSetSize()method across platforms. The platform-specific expectations align with the PR objectives where Windows returns private memory and other platforms return RSS for backward compatibility.oshi-core/src/test/java/oshi/SystemInfoTest.java (1)
335-342: LGTM!The output format is correctly updated to display both resident and private memory values. The column alignment between the header and format string is consistent, and the new
getResidentMemory()andgetPrivateResidentMemory()methods are used appropriately.oshi-core/src/main/java/oshi/driver/windows/registry/ProcessPerformanceData.java (4)
117-140: LGTM! Perf counter method updated consistently.The changes mirror the registry-based method, retrieving both
WORKINGSETPRIVATEandWORKINGSETvalues and passing them to the constructor. The variable naming (privateWorkingSetList,workingSetList) is clear and consistent with existing patterns.
150-174: LGTM! Clean field separation for memory metrics.The
PerfCounterBlocknow correctly encapsulates both:
privateWorkingSetSize- aligns with Windows Task Manager's "Memory" (footprint)workingSetSize- represents true RSS (total physical memory mapped)The immutable pattern is maintained with final private fields.
71-79: LGTM! Constructor call correctly updated for dual memory metrics.The
WORKINGSETPRIVATE(private working set / footprint) andWORKINGSET(total working set / RSS) constants are properly defined in theProcessPerformancePropertyenum and correctly used here to align with the cross-platform memory API design.
197-209: New getters properly expose dual memory metrics.The renamed/new getter methods
getPrivateWorkingSetSize()andgetWorkingSetSize()correctly replace the previousgetResidentSetSize()method on the internalPerfCounterBlockclass. The Javadoc correctly indicates thatworkingSetSizerepresents RSS. All consumers inWindowsOSProcess.updateAttributes()have been updated to use the new getters.
bf36ecd to
8a1cb1a
Compare
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
oshi-core/src/main/java/oshi/software/os/linux/LinuxOSProcess.java (1)
390-402: Guard against potential underflow whenshared > resident.The calculation
(resident - shared) * pageSizeat line 398 assumesresident >= shared. While this should hold under normal kernel accounting (shared pages are a subset of resident pages), edge cases or kernel bugs could potentially causeshared > resident, resulting in a negative value.Consider clamping to zero to ensure non-negative results:
♻️ Proposed defensive fix
long resident = ParseUtil.parseLongOrDefault(statmFields[1], 0L); long shared = ParseUtil.parseLongOrDefault(statmFields[2], 0L); long pageSize = LinuxOperatingSystem.getPageSize(); this.residentSetSize = resident * pageSize; - this.privateResidentMemory = (resident - shared) * pageSize; + this.privateResidentMemory = Math.max(0L, resident - shared) * pageSize;Also, the fallback path now correctly initializes
privateResidentMemory = residentSetSize(line 401), addressing the concern from the previous review.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@oshi-core/src/main/java/oshi/software/os/linux/LinuxOSProcess.java` around lines 390 - 402, In LinuxOSProcess where /proc/[pid]/statm is parsed (the block computing residentSetSize and privateResidentMemory), guard against underflow when computing (resident - shared): compute privateResidentMemory from the non-negative difference (clamp resident - shared to zero) before multiplying by pageSize so privateResidentMemory cannot become negative; keep residentSetSize calculation unchanged and ensure you use the same long types (resident, shared, pageSize) when performing the clamp.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@CHANGELOG.md`:
- Line 4: Update the CHANGELOG entry to mention that getResidentSetSize() is now
deprecated and users should migrate to getResidentMemory() and
getPrivateResidentMemory(); locate the existing bullet that introduces
getResidentMemory() and getPrivateResidentMemory() (the line referencing PR
`#3082`) and append a concise deprecation note stating that getResidentSetSize()
is ambiguous across platforms and will be deprecated, and recommend the two new
methods as replacements.
- Line 3: Change the "##### New Features" heading to a second-level heading so
it increments correctly from the top-level title: replace the string "##### New
Features" with "## New Features" in CHANGELOG.md to fix the MD001 heading-level
violation and match the document's heading structure.
---
Nitpick comments:
In `@oshi-core/src/main/java/oshi/software/os/linux/LinuxOSProcess.java`:
- Around line 390-402: In LinuxOSProcess where /proc/[pid]/statm is parsed (the
block computing residentSetSize and privateResidentMemory), guard against
underflow when computing (resident - shared): compute privateResidentMemory from
the non-negative difference (clamp resident - shared to zero) before multiplying
by pageSize so privateResidentMemory cannot become negative; keep
residentSetSize calculation unchanged and ensure you use the same long types
(resident, shared, pageSize) when performing the clamp.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: d8dd69fd-bea6-41b6-b176-248c8a0152c0
📒 Files selected for processing (12)
CHANGELOG.mdREADME.mdoshi-core-java11/pom.xmloshi-core-java25/pom.xmloshi-core/pom.xmloshi-core/src/main/java/oshi/software/os/linux/LinuxOSProcess.javaoshi-core/src/main/java/oshi/software/os/unix/solaris/SolarisOSProcess.javaoshi-demo/pom.xmloshi-demo/src/main/java/oshi/demo/gui/ProcessPanel.javaoshi-dist/pom.xmlpom.xmlsrc/site/markdown/index.md
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
- GitHub Check: Codacy Static Code Analysis
- GitHub Check: Test JDK 11, macos-latest
- GitHub Check: Test JDK 21, macos-latest
- GitHub Check: Test JDK 25, windows-latest
- GitHub Check: Test JDK 25, macos-latest
- GitHub Check: Test JDK 11, windows-latest
- GitHub Check: Test JDK 21, windows-latest
- GitHub Check: Test JDK 21, ubuntu-latest
- GitHub Check: Analyze (java)
🧰 Additional context used
🪛 markdownlint-cli2 (0.21.0)
CHANGELOG.md
[warning] 3-3: Heading levels should only increment by one level at a time
Expected: h2; Actual: h5
(MD001, heading-increment)
🔇 Additional comments (18)
oshi-demo/src/main/java/oshi/demo/gui/ProcessPanel.java (3)
43-45: LGTM!The column definitions are well-structured. The 10 columns match the 10 width percentages, and the widths sum to 1.0. The addition of separate "RSS" (total resident) and "Memory" (private resident) columns aligns with the PR's goal of exposing both memory metrics clearly.
138-140: LGTM!The sorting logic correctly uses
getPrivateResidentMemory()to match the "Memory" column display. The default fallback togetResidentMemory()on platforms without explicit implementations ensures consistent behavior.
167-172: LGTM!The data population correctly maps to the column definitions:
- Index 6 → "RSS" using
getResidentMemory()- Index 7 → "Memory" using
getPrivateResidentMemory()- Index 8 → "% Memory" calculated from private resident memory
- Index 9 → "Process Name"
The percentage calculation appropriately uses private resident memory to reflect the process's individual memory footprint relative to total system memory.
oshi-core-java25/pom.xml (1)
8-8: LGTM!Parent version bump to 6.11.0-SNAPSHOT is consistent with the coordinated multi-module version update.
oshi-core-java11/pom.xml (1)
8-8: LGTM!Parent version bump aligns with the coordinated 6.11.0-SNAPSHOT release across all modules.
src/site/markdown/index.md (1)
53-55: LGTM!SNAPSHOT download links correctly updated to 6.11.0-SNAPSHOT for all three module variants (JDK8, JPMS, FFM).
oshi-demo/pom.xml (1)
8-8: LGTM!Parent version bump is consistent with the project-wide 6.11.0-SNAPSHOT update.
README.md (1)
53-55: LGTM!SNAPSHOT download links updated consistently with the site documentation (index.md).
pom.xml (1)
7-7: LGTM!Root POM version bump to 6.11.0-SNAPSHOT correctly establishes the baseline for all child modules.
oshi-core/pom.xml (1)
8-8: LGTM!Parent version bump aligns oshi-core with the 6.11.0-SNAPSHOT release containing the new memory footprint API.
oshi-dist/pom.xml (1)
8-8: LGTM!Parent version bump ensures distribution packaging aligns with the 6.11.0-SNAPSHOT release.
oshi-core/src/main/java/oshi/software/os/unix/solaris/SolarisOSProcess.java (4)
81-81: LGTM!The new
residentSetSizePrivatefield aligns with the broader API changes introducing separate resident memory metrics across platforms.
200-207: LGTM!The API changes correctly implement the new memory semantics:
getResidentMemory()returns the existingresidentSetSize(true RSS)getPrivateResidentMemory()returns the newresidentSetSizePrivatefieldThis aligns with the cross-platform API design documented in
OSProcess.javacontext snippet 1.
403-421: Formatting-only changes in switch block.These are indentation/formatting changes with no behavioral impact. The switch logic correctly maps Solaris process state characters to the
Stateenum.
371-371: The multiplication by 1024 is correct.Oracle Solaris documentation confirms that
psinfo_t.pr_rssizeprivis measured in kilobytes, so the conversion to bytes via multiplication by 1024 is accurate. The existing comment at line 368 ("These are in KB, multiply") correctly applies to this field.oshi-core/src/main/java/oshi/software/os/linux/LinuxOSProcess.java (3)
87-87: LGTM!The new
privateResidentMemoryfield aligns with the broader API changes and matches the naming convention used in the macOS implementation.
213-220: LGTM!The API changes correctly implement the new memory semantics:
getResidentMemory()returnsresidentSetSize(true RSS)getPrivateResidentMemory()returnsprivateResidentMemory(computed from statm)This aligns with the interface contract in
OSProcess.javaand matches other platform implementations.
358-358: LGTM!Reading
/proc/[pid]/statmis appropriate for obtaining the resident and shared page counts needed to compute private memory.
8a1cb1a to
7b99010
Compare
Added a default implementation for getMemoryFootprint method to provide a process memory footprint estimate.
Implement macOS process memory footprint getting it from rUsageInfoV2.ri_phys_footprint
Added a comparator for sorting processes by memory footprint size.
Added a new PathElement for physical footprint tracking.
72e2828 to
91d9038
Compare
|
@dbwiddis thank you so much, you are a code machine :). |

Add getMemoryFootprint method on OSProcess class.
The objective is get a memory size value like in end user task manager.
In linux and Windows RSS value appears to be ok, but on macOS values showed in "Activity Monitor" are very different of it.
Summary by CodeRabbit
New Features
Tests
Documentation