Created
February 28, 2023 14:34
-
-
Save sj-i/23cdda81bf031688108a889b728e982b to your computer and use it in GitHub Desktop.
Passing a callback to PHP FFI eats up memory because some internal data is not released until the end of the request
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| use FFI\CData; | |
| $ffi = FFI::cdef('void qsort(void *base, size_t num, size_t size, int (*compare)(const void*, const void*));'); | |
| $arr = FFI::new('int[2]'); | |
| $arr[0] = 1; | |
| $arr[1] = 2; | |
| while (true) { | |
| $ffi->qsort($arr, 2, FFI::sizeof($arr[0]), fn(CData $a, CData $b) => 0); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment