Skip to content

Commit 691acac

Browse files
authored
fix: correct docs and type of "resident_memory_used_MB" attribute (#4824)
It was implemented as int, documented as float. Change the docs to match what was always indended (int), and also switch the implementation so that either int or float will be transparently accepted. Signed-off-by: Larry Gritz <lg@larrygritz.com>
1 parent 70636df commit 691acac

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

src/include/OpenImageIO/imageio.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3974,7 +3974,7 @@ inline bool attribute (string_view name, string_view val) {
39743974
/// List of library dependencieis (where known) and versions, separatd by
39753975
/// semicolons. (Added in OpenImageIO 2.5.8.)
39763976
///
3977-
/// - `float resident_memory_used_MB`
3977+
/// - `int resident_memory_used_MB`
39783978
///
39793979
/// This read-only attribute can be used for debugging purposes to report
39803980
/// the approximate process memory used (resident) by the application, in

src/libOpenImageIO/imageio.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,10 @@ getattribute(string_view name, TypeDesc type, void* val)
634634
*(int*)val = int(Sysutil::memory_used(true) >> 20);
635635
return true;
636636
}
637+
if (name == "resident_memory_used_MB" && type == TypeFloat) {
638+
*(float*)val = float(Sysutil::memory_used(true) >> 20);
639+
return true;
640+
}
637641
if (name == "missingcolor" && type.basetype == TypeDesc::FLOAT
638642
&& oiio_missingcolor.size()) {
639643
// missingcolor as float array

0 commit comments

Comments
 (0)