konsumer / konsumer/raylib-pointers
Potential memory leak
- Dominant language
- C
- Stars
- 0
- Forks
- 1
- PR merge metrics
- No merged PRs in 30d
Description
It seems memory will be leaked if you allocate more pointers than `FRAME_ALLOC_SIZE`, or `1024*512`, or `524,288`.
https://github.com/konsumer/raylib-pointers/blob/7f2340c4b82fd13e4f00fe682c8b234e3b043ae9/tools/gen_lib.js#L52
Here's where you free only up to `_frame_alloc_counter`.
https://github.com/konsumer/raylib-pointers/blob/7f2340c4b82fd13e4f00fe682c8b234e3b043ae9/tools/gen_lib.js#L63
A few solutions off the top of my head:
1. Show some warning when reaching the limit to make the memory leak obvious.
2. Remove `FRAME_ALLOC_SIZE` altogether. I think a good way to do that is to only ever have one pointer allocated that'll be used to carry the result, but is freed on the next raylib-function call. Then the receiving/duping/allocating can be done by JS on the JS side, instead of the C side.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start in tools/gen_lib.js at the allocation around line 52 and the cleanup around line 63. Trace what happens when allocations exceed FRAME_ALLOC_SIZE, then determine whether the project should warn at the limit or remove the fixed allocation approach. Done means the excess-allocation case no longer silently leaks, with the chosen behavior documented or verified.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, javascript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100