-
-
Notifications
You must be signed in to change notification settings - Fork 144
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
[TODO] Memory limit feature #198
Comments
Hi, I'm currently looking into adding custom allocator support to TinyEXR. I started by simply replacing malloc/free with TINYEXR_MALLOC / TINYEXR_FREE macros that I can define within the cpp implementation file, to route allocations to a custom global allocator. This is a rather unintrusive change, easy to whip up a small PR for. |
👍 > I'm currently looking into adding custom allocator support to TinyEXR
Where can I find such allocator override in STB project? https://github.com/nothings/stb/blob/master/stb_image.h Anyway, yes, having userdata pointer is the preferred approach.
(FYI stb_image uses this approach in io callback https://github.com/nothings/stb/blob/ae721c50eaf761660b4f90cc590453cdb0c2acd0/stb_image.h#L410 ) We'll then need to introduce new API which takes this callback in its argument
For backward compatibility, existing API uses default allocator. |
You're right, it's not consistent in all the STB libs. I saw this in stb_image_resize2.h:
That's definitely the cleanest approach! |
Oh, Thanks! > I saw this in stb_image_resize2.h
Yes, realloc is not used in TinyEXR, so we can omit it. just |
Describe the issue
Currently TinyEXR does not support capping memory consumption.
Without such feature, the app may trigger OOM for large EXR images.
To Reproduce
Run poc2 and poc2 in issue 197.
Expected behavior
Add feature to specify the maximum memory to use. This requires
It also require implementing tracking memory consumption in TinyEXR .
Environment
N/A
The text was updated successfully, but these errors were encountered: