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

Use user defined allocator/deallocator #49

Closed
wants to merge 2 commits into from

Conversation

Watson1978
Copy link

@Watson1978 Watson1978 commented Jun 3, 2019

Now, I'm fighting to reduce memory usage in RMagick which is Ruby ImageMagick bridging.

To work Ruby's GC correctly, we need to know ImageMagick allocated memory size at runtime.
Because Ruby decides whether to run GC by current memory usage.
And the memory usage need to contain Ruby bridging (RMagick) and library (ImageMagick).

If it could notify total allocated memory size (RMagick + ImageMagick) to Ruby correctly,
Ruby's GC will work well and reduce application memory usage.

So, if ImageMagick has used Ruby's allocator configured by SetMagickMemoryMethods(),
Ruby can calculate the memory usage automatically.

This PR makes it possible to refer to a user defined allocator in where using malloc/free directly.

By this PR, it reduce RMagick memory usage from blue line to red line.

memory_usage2

Related to rmagick/rmagick#697

@urban-warrior
Copy link
Member

urban-warrior commented Jun 5, 2019

Its OK to utilize Acquire/RelinquishMagickMemory() in the opencl.c/memory.c source modules, however, malloc() must remain in the semaphore.c source module. Since we cannot apply your entire pull request, we'll selectively apply your patch.

@Watson1978
Copy link
Author

@urban-warrior Thank you for applying a patch. I found a typo. Please fix it ( a7ae3f4#r33815166 )

@Watson1978
Copy link
Author

@urban-warrior Even without fixing semaphore.c, seems it brings big impact to our memory management 🎉 Thanks a lot.

@Watson1978 Watson1978 closed this Jun 5, 2019
netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this pull request Jun 11, 2019
2019-06-08  7.0.8-49 Cristy  <quetzlzacatenango@image...>
  * Release ImageMagick version 7.0.8-49, GIT revision 15708:6d7e1db:20190608

2019-06-03  7.0.8-49 Cristy  <quetzlzacatenango@image...>
  * Add support for RGB565 image format (reference
    https://imagemagick.org/discourse-server/viewtopic.php?f=2&t=36078).
  * Use user defined allocator instead of `malloc` (reference
    ImageMagick/ImageMagick6#49).
  * Add static decorator to accelerator kernels (reference
    ImageMagick/ImageMagick#1366).

2019-06-01  7.0.8-48 Cristy  <quetzlzacatenango@image...>
  * Release ImageMagick version 7.0.8-48, GIT revision 15689:061a3bb82:20190601

2019-06-01  7.0.8-48 Cristy  <quetzlzacatenango@image...>
  * Fix transient convolution bug (reference
    https://imagemagick.org/discourse-server/viewtopic.php?f=3&t=36119).

2019-05-26  7.0.8-47 Cristy  <quetzlzacatenango@image...>
  * Release ImageMagick version 7.0.8-47, GIT revision 15681:5cffc6cbb:20190526

2019-05-19  7.0.8-47 Cristy  <quetzlzacatenango@image...>
  * Support 16 and 32 bit tiled float TIFF images.
  * Convolve morphology alpha channel fix (reference
    https://imagemagick.org/discourse-server/viewtopic.php?f=3&t=36086).
  * Text improvements to the internal SVG renderer.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants