Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed

Conversation

lgritz
Copy link
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 <[email protected]>
@lgritz
Copy link
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
Signed-off-by: Zach Lewis <[email protected]>
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 <[email protected]>
Signed-off-by: Zach Lewis <[email protected]>
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