obsproject / obsproject/obs-studio
Memory leak at reconnecting RTMP
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 76.4k
- Forks
- 10.2k
- Avg merge
- 4d 23h
- Merged PRs (30d)
- 12
Description
Operating System Info
Other
Other OS
Fedora 37
OBS Studio Version
Git
OBS Studio Version (Other)
30.0.0-rc1-120-g2d6b6ce05-modified
OBS Studio Log URL
https://obsproject.com/logs/CLbSFxJDmO5eyTqs
OBS Studio Crash Log URL
No response
Expected Behavior
No memory leak
Current Behavior
There is one memory leak
Steps to Reproduce
- Configure as below
- Enable
Stream Delay - Ensure
Preserve cutoff point (increase delay) when reconnectingis enabled (default).
- Enable
- Start nginx with the RTMP module
- Start the streaming
- Wait until
==== Streaming Start ===============================================is displayed on the log. - Immediately kill the RTMP server
- Stop the streaming
- Exit OBS
Anything else we should know?
A modification below resolved the memory leak. However, I'm afraid it's the right fix. It might be better to just peek the front packet and drop the packet after the packet has correctly been sent.
diff --git a/plugins/obs-outputs/rtmp-stream.c b/plugins/obs-outputs/rtmp-stream.c
index dab8cdd27..ffbbf4235 100644
--- a/plugins/obs-outputs/rtmp-stream.c
+++ b/plugins/obs-outputs/rtmp-stream.c
@@ -659,6 +659,7 @@ static void *send_thread(void *data)
if (!stream->sent_headers) {
if (!send_headers(stream)) {
os_atomic_set_bool(&stream->disconnected, true);
+ obs_encoder_packet_release(&packet);
break;
}
}
### Tasks
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in plugins/obs-outputs/rtmp-stream.c at send_thread and review the reconnect path around send_headers and packet ownership. Reproduce the Fedora 37 scenario with nginx and the RTMP module using stream delay and preserve-cutoff enabled. Done means the reconnect-and-exit sequence no longer reports the memory leak, with the correct packet handling verified.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c
- Domain
- audio-video-rtc, networking
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100