Skip to content

api: add memsize() methods to ParamValueList and ImageSpec#4317

Closed
lgritz wants to merge 2 commits intoAcademySoftwareFoundation:masterfrom
lgritz:lg-imagespecsize
Closed

api: add memsize() methods to ParamValueList and ImageSpec#4317
lgritz wants to merge 2 commits intoAcademySoftwareFoundation:masterfrom
lgritz:lg-imagespecsize

Conversation

@lgritz
Copy link
Copy Markdown
Collaborator

@lgritz lgritz commented Jul 1, 2024

To aid some memory accounting, add a method to ParamValueList and
ImageSpec that return the memory cost (the size of the struct and all
the allocated things hanging off of it). We're trying to be more
careful about understanding how much memory is used by having many
copies of ImageSpec's lying around.

Have ImageCache stats estimate how much mem is tied up in ImageSpecs.

lgritz added 2 commits June 30, 2024 21:09
To aid some memory accounting, add a method to ParamValueList and
ImageSpec that return the memory cost (the size of the struct and all
the allocated things hanging off of it). We're trying to be more
careful about understanding how much memory is used by having many
copies of ImageSpec's lying around.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
Signed-off-by: Larry Gritz <lg@larrygritz.com>
@lgritz
Copy link
Copy Markdown
Collaborator Author

lgritz commented Jul 11, 2024

Withdrawing in favor of #4322

@lgritz lgritz closed this Jul 11, 2024
lgritz pushed a commit that referenced this pull request Aug 11, 2024
… memory tracking (#4322)

First PR of two, following @lgritz and I discussions on memory tracking
in the OIIO::ImageCache.
- Add two template methods and their specializations for types various
to help memory tracking:
```c++
// return the total heap allocated memory held by the object and its members
template<typename T> inline size_t heapsize(const T& t);
// return the total memory footprint including the size of the structure itself
template<typename T> inline size_t footprint(const T& t);
```
- Specialized for: ParamValue, ParamValueList, ImageSpec, ImageInput,
ImageOutput, std::vector, std::shared_ptr, std::unique_ptr,
oiio::intrusive_ptr, ImageCacheImpl related objects.
- New files: 
- `include/memory.h` : adds base and few types specialization of
heapsize and footprint.
- `libtexture/imagecache_memory_pvt.h` : adds specilializations for
ImageCacheImpl and related objects.
- `libtexture/imagecache_memory_print.h` : adds a helper function that
print a breakdown of the ImageCacheImpl total memory usage as well, as
well as per image format. Note: this is slow, but gives accurate memory
estimation.

Related PR from Larry :
#4317

Signed-off-by: Basile Fraboni <basile.fraboni@gmail.com>
lgritz pushed a commit that referenced this pull request Sep 2, 2024
…utput (#4323)

Second PR of two, following @lgritz and I discussions on memory tracking
in the OIIO::ImageCache.

- the memory tracking system from
#4322 is
not sufficient to track OIIO public objects that can be overriden.
- add virtual `heapsize()` method to ImageInput and ImageOutput that
return the total heap allocated memory held by the structure and its
members.
- [ ] **TODO**: override for every internal OIIO type (bmp, tiff, etc). 

Related PR from Larry :
#4317
First PR:
#4322

Signed-off-by: Basile Fraboni <basile.fraboni@gmail.com>
zachlewis pushed a commit to zachlewis/OpenImageIO that referenced this pull request Sep 16, 2024
… memory tracking (AcademySoftwareFoundation#4322)

First PR of two, following @lgritz and I discussions on memory tracking
in the OIIO::ImageCache.
- Add two template methods and their specializations for types various
to help memory tracking:
```c++
// return the total heap allocated memory held by the object and its members
template<typename T> inline size_t heapsize(const T& t);
// return the total memory footprint including the size of the structure itself
template<typename T> inline size_t footprint(const T& t);
```
- Specialized for: ParamValue, ParamValueList, ImageSpec, ImageInput,
ImageOutput, std::vector, std::shared_ptr, std::unique_ptr,
oiio::intrusive_ptr, ImageCacheImpl related objects.
- New files:
- `include/memory.h` : adds base and few types specialization of
heapsize and footprint.
- `libtexture/imagecache_memory_pvt.h` : adds specilializations for
ImageCacheImpl and related objects.
- `libtexture/imagecache_memory_print.h` : adds a helper function that
print a breakdown of the ImageCacheImpl total memory usage as well, as
well as per image format. Note: this is slow, but gives accurate memory
estimation.

Related PR from Larry :
AcademySoftwareFoundation#4317

Signed-off-by: Basile Fraboni <basile.fraboni@gmail.com>
Signed-off-by: Zach Lewis <zachcanbereached@gmail.com>
zachlewis pushed a commit to zachlewis/OpenImageIO that referenced this pull request Sep 16, 2024
…utput (AcademySoftwareFoundation#4323)

Second PR of two, following @lgritz and I discussions on memory tracking
in the OIIO::ImageCache.

- the memory tracking system from
AcademySoftwareFoundation#4322 is
not sufficient to track OIIO public objects that can be overriden.
- add virtual `heapsize()` method to ImageInput and ImageOutput that
return the total heap allocated memory held by the structure and its
members.
- [ ] **TODO**: override for every internal OIIO type (bmp, tiff, etc). 

Related PR from Larry :
AcademySoftwareFoundation#4317
First PR:
AcademySoftwareFoundation#4322

Signed-off-by: Basile Fraboni <basile.fraboni@gmail.com>
Signed-off-by: Zach Lewis <zachcanbereached@gmail.com>
scott-wilson pushed a commit to scott-wilson/OpenImageIO that referenced this pull request May 18, 2025
… memory tracking (AcademySoftwareFoundation#4322)

First PR of two, following @lgritz and I discussions on memory tracking
in the OIIO::ImageCache.
- Add two template methods and their specializations for types various
to help memory tracking:
```c++
// return the total heap allocated memory held by the object and its members
template<typename T> inline size_t heapsize(const T& t);
// return the total memory footprint including the size of the structure itself
template<typename T> inline size_t footprint(const T& t);
```
- Specialized for: ParamValue, ParamValueList, ImageSpec, ImageInput,
ImageOutput, std::vector, std::shared_ptr, std::unique_ptr,
oiio::intrusive_ptr, ImageCacheImpl related objects.
- New files:
- `include/memory.h` : adds base and few types specialization of
heapsize and footprint.
- `libtexture/imagecache_memory_pvt.h` : adds specilializations for
ImageCacheImpl and related objects.
- `libtexture/imagecache_memory_print.h` : adds a helper function that
print a breakdown of the ImageCacheImpl total memory usage as well, as
well as per image format. Note: this is slow, but gives accurate memory
estimation.

Related PR from Larry :
AcademySoftwareFoundation#4317

Signed-off-by: Basile Fraboni <basile.fraboni@gmail.com>
Signed-off-by: Scott Wilson <scott@propersquid.com>
scott-wilson pushed a commit to scott-wilson/OpenImageIO that referenced this pull request May 18, 2025
…utput (AcademySoftwareFoundation#4323)

Second PR of two, following @lgritz and I discussions on memory tracking
in the OIIO::ImageCache.

- the memory tracking system from
AcademySoftwareFoundation#4322 is
not sufficient to track OIIO public objects that can be overriden.
- add virtual `heapsize()` method to ImageInput and ImageOutput that
return the total heap allocated memory held by the structure and its
members.
- [ ] **TODO**: override for every internal OIIO type (bmp, tiff, etc).

Related PR from Larry :
AcademySoftwareFoundation#4317
First PR:
AcademySoftwareFoundation#4322

Signed-off-by: Basile Fraboni <basile.fraboni@gmail.com>
Signed-off-by: Scott Wilson <scott@propersquid.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant