Skip to content

Possible memory leak on nack package #328

Closed as not planned
Closed as not planned

Description

@tubzby

I have an SFU program using ion-sfu (modified a bit since the original repo is outdated), which depends on interceptor v0.1.37.

Recently, we noticed that the memory usage of this process has been increasing over the past few days, the graph looks like:

Image

So I use go tool pprof to get the heap output and then found out that most of the active memory was allocated by the nack package:

Image

Image

top of pprof:

(pprof) top
Showing nodes accounting for 4.89GB, 88.17% of 5.55GB total
Dropped 522 nodes (cum <= 0.03GB)
Showing top 10 nodes out of 106
      flat  flat%   sum%        cum   cum%
    3.55GB 63.91% 63.91%     3.55GB 63.91%  github.com/pion/interceptor/pkg/nack.newPacketManager.func2
    0.41GB  7.38% 71.30%     0.41GB  7.38%  github.com/pion/webrtc/v4/pkg/media/samplebuilder.New
    0.28GB  5.04% 76.34%     0.28GB  5.04%  gdcx.com/sfu/cluster.NewSFU.NewBufferFactory.func1
    0.24GB  4.25% 80.59%     3.97GB 71.49%  github.com/pion/interceptor/pkg/nack.(*packetManager).NewPacket
    0.18GB  3.33% 83.91%     0.18GB  3.33%  github.com/pion/interceptor/pkg/nack.newPacketManager.func1
    0.09GB  1.54% 85.45%     0.09GB  1.54%  github.com/pion/transport/v3/packetio.(*Buffer).grow
    0.05GB  0.87% 86.32%     0.05GB  0.87%  syscall.NetlinkRIB
    0.04GB  0.69% 87.00%     0.04GB  0.69%  log.New
    0.03GB  0.61% 87.61%     0.03GB  0.61%  github.com/pion/sdp/v3.(*unmarshalCache).cloneMediaAttributes
    0.03GB  0.56% 88.17%     0.05GB  0.81%  github.com/pion/webrtc/v4/pkg/media/samplebuilder.(*SampleBuilder).buildSample
(pprof)

Is this a memory leak? How could I debug/solve it?

Activity

  1. changed the title [-]Possible memory leak on nack poll[/-] [+]Possible memory leak on nack package[/+] on May 9, 2025
  2. Qizot commented on Jul 18, 2025

    @Qizot

    I've observed the same problem. Can't really pin-point any problems in the code itself, maybe it has something to do with the sync.Pool itself?

  3. tubzby commented on Jul 18, 2025

    @tubzby
    Author

    @Qizot Althogh I havn't fixed it yet, it's quite possible that PeerConnection or something related were hold by App layer by accident.

    By hold I mean keep a reference or never close it.

  4. Qizot commented on Jul 18, 2025

    @Qizot

    I mean I experience the same issue. I've checked all the app code several times and the only potential leak must be in some libraries (unless I lost my sanity along the way).

    It's not like I'm leaking huge number of memory, I have just 1:1 calls and on average I leak ~30KB per session which would be couple of packets at most but with thousands of sessions it adds up and drains all the memory after like 1,5 weeks and I need to restart the machine.

    From the memory profiles I haven't seen anything big besides the nack module (I have a copied version from the repo and am using it in some other module but the code is the same) so seeing that you have a similar problem gave me a little more hope.

    By hold I mean keep a reference or never close it.

    Not closing it probably woulld show up in the number of goroutines and in my case those are not ever-increasing.

  5. Qizot commented on Jul 18, 2025

    @Qizot

    I am also wondering if that has something to do maybe with the ion code? I have part of the codebase that has code taken from livekit (mainly handling of the peer connection) but as far as I know the livekit also has a quite big chunk from ion sfu.

  6. JoTurk commented on Jul 18, 2025

    @JoTurk
    Member

    I can make a simple application to try to debug that, maybe we have a memory leak. I can try something this weekend!

  7. tubzby commented on Jul 18, 2025

    @tubzby
    Author

    I am also wondering if that has something to do maybe with the ion code? I have part of the codebase that has code taken from livekit (mainly handling of the peer connection) but as far as I know the livekit also has a quite big chunk from ion sfu.

    I'm also using ion, if sfu.PeerLocal never closed, the room never get closed, it causes leaks exactly like this, and it never increase the grouting number, you should go through your code to see if you missed to handle some ICE state change event.

  8. JoTurk commented on Jul 18, 2025

    @JoTurk
    Member

    Did you guys see that Ion is getting a reboot / remake, if you have any ideas for stuff you want to have or want to contribute please share your ideas, we're working on the draft right now pion/ion#1

  9. tubzby commented on Jul 18, 2025

    @tubzby
    Author

    Did you guys see that Ion is getting a reboot / remake, if you have any ideas for stuff you want to have or want to contribute please share your ideas, we're working on the draft right now pion/ion#1

    Oh yea!

    For one thing I'm now working on related to ion: adding rtmp ingress support.

  10. Sean-Der commented on Jul 18, 2025

    @Sean-Der
    Member

    @tubzby I am curious what clients don't have WHIP support (still need RTMP)?

  11. tubzby commented on Jul 18, 2025

    @tubzby
    Author

    @Sean-Der I am working with some industrial drone product, it support rtmp only.

  12. JoTurk commented on Jul 18, 2025

    @JoTurk
    Member

    @Sean-Der I am working with some industrial drone product, it support rtmp only.

    @tubzby I'm curious if it's e-rtmp or normal rtmp, and if it's rtmp do you transcode the audio inside the sfu?

  13. Sean-Der commented on Jul 18, 2025

    @Sean-Der
    Member

    @tubzby aye, no way around that :)

    Would be great to get RTMP support into Ion. I would love to also make it all Pure Go. If we ingest AAC would be really cool if we could get a Pure Go decoder. Would be fun to work on.

  14. tubzby commented on Jul 18, 2025

    @tubzby
    Author

    @Sean-Der I am working with some industrial drone product, it support rtmp only.

    @tubzby I'm curious if it's e-rtmp or normal rtmp, and if it's rtmp do you transcode the audio inside the sfu?

    It's normal rtmp and we don't need audio support for a drone, it's nothing but noise for a drone:)

  15. tubzby commented on Jul 18, 2025

    @tubzby
    Author

    @tubzby aye, no way around that :)

    Would be great to get RTMP support into Ion. I would love to also make it all Pure Go. If we ingest AAC would be really cool if we could get a Pure Go decoder. Would be fun to work on.

    Yes, H264 and ACC, pure standard.

  16. 1 remaining item

  17. Qizot commented on Jul 21, 2025

    @Qizot

    @joeturki

    I can make a simple application to try to debug that, maybe we have a memory leak. I can try something this weekend!

    I've been doing a lot of semi-synthetic testing, and I couldn't reproduce it. It only happened on production so in fact it may have something to do with handling ICE states (with testing it is hard to reproduce what users are actually experiencing). What is more strange is that the leak is constant and is not that high per session, I would expect if we leak nack packets it would be in MBs instead of couple of KBs (but I may be wrong, maybe it happens sporadically and with prod traffic it is not noticable?).

  18. Qizot commented on Jul 22, 2025

    @Qizot

    Actually @tubzby might have been right about not properly closing something. I doubt it have anything to do with the interceptor itself. I've just checked the garbage collection of my session entity and for very little amount of sessions it doesn't get cleaned up.

  19. JoTurk commented on Jul 22, 2025

    @JoTurk
    Member

    I tried for a bit and i didn't find anything, maybe we have something that is hard to close / clean? keep us updated

  20. Qizot commented on Aug 7, 2025

    @Qizot

    The package indeed is not leaking. Found a bug on my side with a leaking goroutine (custom congestion control) that was keeping a reference to the peer connection, effectively keeping the interceptor.

  21. JoTurk commented on Aug 9, 2025

    @JoTurk
    Member

    Thank you for the update <3

  22. tubzby commented on Sep 25, 2025

    @tubzby
    Author

    @joeturki Sorry to bring this up, I have observed from go tool pprof that sync.Pool in this crate consumed 1832MB of memory, with only 5 tracks uploading, from the code it should be only: 5 * 1024(max packet per track) * 1460(MTU) ~ 7.5MB.

    If memory consumption is that large, I'm leaking tracks/pcs, am I correct?

  23. Qizot commented on Sep 25, 2025

    @Qizot

    @tubzby sync.Pool on its own is doing garbage collection (or rather let's garbage collection claim some objects) so the memory leaked is in the objects that something else is holding. Are you sure you are not leaking some goroutines? For me even small amount (like 100) greatly contributed to the overall memory usage.

  24. tubzby commented on Sep 25, 2025

    @tubzby
    Author

    @Qizot, I have checked the goroutines, nothing unusual.

  25. philipch07 commented on Dec 1, 2025

    @philipch07
    Member

    @tubzby @Qizot @paragonov I fixed a memory leak in the nack package in #386. Please let me know if it fixes the problem. Thanks!

  26. tubzby commented on Dec 2, 2025

    @tubzby
    Author

    @philipch07 Ok, I have switched to this branch pch07/fix-nack-deadlocks

  27. philipch07 commented on Dec 2, 2025

    @philipch07
    Member

    @tubzby I just merged the branch in 1209fc9, so you can go off of master now. I also merged a fix for some rare deadlocks, but that's a different issue. I believe we're aiming for a new tag in the coming days depending on a couple PRs, so hopefully that comes out soon.

    Let me know if you're still seeing some memory leaks!

  28. tubzby commented on Dec 4, 2025

    @tubzby
    Author

    The process running for about 12 hours, then I force it to close all the sessions, after several hours the process was still holding 7GB memory. I have saved the heap file, it's almost the same from the begening, I have also checked the goroutines, looks quite clean.

    I feel like it might related to something inside ion-sfu which might accidentally hold something that prevent the object to get collected, how to debug that?

    goutines:

    goroutine profile: total 15
    1 @ 0x28044 0x90060 0x17ec4c 0x95ce4
    #	0x9005f		os/signal.signal_recv+0x2f	/localdata/linuxbrew/.linuxbrew/Cellar/go/1.25.3/libexec/src/runtime/sigqueue.go:152
    #	0x17ec4b	os/signal.loop+0x1b		/localdata/linuxbrew/.linuxbrew/Cellar/go/1.25.3/libexec/src/os/signal/signal_unix.go:23
    
    1 @ 0x4d02c 0x8ca04 0xcda1c4 0xcd9ff0 0xcd7764 0xcec784 0x113fbe4 0x112a468 0x11454d4 0x112a468 0x11474d4 0x112a468 0x1135ab4 0x11355f4 0x560d30 0x542e88 0x95ce4
    #	0xcda1c3	runtime/pprof.writeRuntimeProfile+0xb3				/localdata/linuxbrew/.linuxbrew/Cellar/go/1.25.3/libexec/src/runtime/pprof/pprof.go:788
    #	0xcd9fef	runtime/pprof.writeGoroutine+0x4f				/localdata/linuxbrew/.linuxbrew/Cellar/go/1.25.3/libexec/src/runtime/pprof/pprof.go:747
    #	0xcd7763	runtime/pprof.(*Profile).WriteTo+0x143				/localdata/linuxbrew/.linuxbrew/Cellar/go/1.25.3/libexec/src/runtime/pprof/pprof.go:371
    #	0xcec783	net/http/pprof.handler.ServeHTTP+0x413				/localdata/linuxbrew/.linuxbrew/Cellar/go/1.25.3/libexec/src/net/http/pprof/pprof.go:272
    #	0x113fbe3	github.com/gin-contrib/pprof.RouteRegister.WrapH.func9+0x53	/home/zpl/go/pkg/mod/github.com/gin-gonic/[email protected]/utils.go:49
    #	0x112a467	github.com/gin-gonic/gin.(*Context).Next+0x67			/home/zpl/go/pkg/mod/github.com/gin-gonic/[email protected]/context.go:192
    #	0x11454d3	gdcx.com/sfu/rest.(*Rest).Start.auth.func15+0xe3		/home/zpl/src/sfu.work/sfu/rest/http.go:127
    #	0x112a467	github.com/gin-gonic/gin.(*Context).Next+0x67			/home/zpl/go/pkg/mod/github.com/gin-gonic/[email protected]/context.go:192
    #	0x11474d3	gdcx.com/sfu/rest.(*Rest).Start.CORSMiddleware.func14+0x113	/home/zpl/src/sfu.work/sfu/rest/http.go:103
    #	0x112a467	github.com/gin-gonic/gin.(*Context).Next+0x67			/home/zpl/go/pkg/mod/github.com/gin-gonic/[email protected]/context.go:192
    #	0x1135ab3	github.com/gin-gonic/gin.(*Engine).handleHTTPRequest+0x313	/home/zpl/go/pkg/mod/github.com/gin-gonic/[email protected]/gin.go:689
    #	0x11355f3	github.com/gin-gonic/gin.(*Engine).ServeHTTP+0x153		/home/zpl/go/pkg/mod/github.com/gin-gonic/[email protected]/gin.go:643
    #	0x560d2f	net/http.serverHandler.ServeHTTP+0xaf				/localdata/linuxbrew/.linuxbrew/Cellar/go/1.25.3/libexec/src/net/http/server.go:3340
    #	0x542e87	net/http.(*conn).serve+0x527					/localdata/linuxbrew/.linuxbrew/Cellar/go/1.25.3/libexec/src/net/http/server.go:2109
    
    1 @ 0x8dc70 0x22f28 0x22ac4 0x1149fcc 0x57ec8 0x95ce4
    #	0x1149fcb	main.main+0x11bb	/home/zpl/src/sfu.work/sfu/main.go:277
    #	0x57ec7		runtime.main+0x277	/localdata/linuxbrew/.linuxbrew/Cellar/go/1.25.3/libexec/src/runtime/proc.go:285
    
    1 @ 0x8dc70 0x22f28 0x22ae4 0xae9008 0x95ce4
    #	0xae9007	gdcx.com/sfu/mq.(*mq).Connect.func2+0x47	/home/zpl/src/sfu.work/sfu/mq/mq.go:104
    
    1 @ 0x8dc70 0x22f28 0x22ae4 0xc926f4 0x95ce4
    #	0xc926f3	gdcx.com/sfu/storage.(*Uploader).uploadRoutine+0x83	/home/zpl/src/sfu.work/sfu/storage/uploader.go:65
    
    1 @ 0x8dc70 0x50bc0 0x8ce60 0x107408 0x108620 0x108611 0x158818 0x169054 0x53def8 0x95ce4
    #	0x8ce5f		internal/poll.runtime_pollWait+0x9f		/localdata/linuxbrew/.linuxbrew/Cellar/go/1.25.3/libexec/src/runtime/netpoll.go:351
    #	0x107407	internal/poll.(*pollDesc).wait+0x27		/localdata/linuxbrew/.linuxbrew/Cellar/go/1.25.3/libexec/src/internal/poll/fd_poll_runtime.go:84
    #	0x10861f	internal/poll.(*pollDesc).waitRead+0x1df	/localdata/linuxbrew/.linuxbrew/Cellar/go/1.25.3/libexec/src/internal/poll/fd_poll_runtime.go:89
    #	0x108610	internal/poll.(*FD).Read+0x1d0			/localdata/linuxbrew/.linuxbrew/Cellar/go/1.25.3/libexec/src/internal/poll/fd_unix.go:165
    #	0x158817	net.(*netFD).Read+0x27				/localdata/linuxbrew/.linuxbrew/Cellar/go/1.25.3/libexec/src/net/fd_posix.go:68
    #	0x169053	net.(*conn).Read+0x33				/localdata/linuxbrew/.linuxbrew/Cellar/go/1.25.3/libexec/src/net/net.go:196
    #	0x53def7	net/http.(*connReader).backgroundRead+0x37	/localdata/linuxbrew/.linuxbrew/Cellar/go/1.25.3/libexec/src/net/http/server.go:702
    
    1 @ 0x8dc70 0x50bc0 0x8ce60 0x107408 0x108620 0x108611 0x158818 0x169054 0xb9db68 0xb9d550 0x95ce4
    #	0x8ce5f		internal/poll.runtime_pollWait+0x9f			/localdata/linuxbrew/.linuxbrew/Cellar/go/1.25.3/libexec/src/runtime/netpoll.go:351
    #	0x107407	internal/poll.(*pollDesc).wait+0x27			/localdata/linuxbrew/.linuxbrew/Cellar/go/1.25.3/libexec/src/internal/poll/fd_poll_runtime.go:84
    #	0x10861f	internal/poll.(*pollDesc).waitRead+0x1df		/localdata/linuxbrew/.linuxbrew/Cellar/go/1.25.3/libexec/src/internal/poll/fd_poll_runtime.go:89
    #	0x108610	internal/poll.(*FD).Read+0x1d0				/localdata/linuxbrew/.linuxbrew/Cellar/go/1.25.3/libexec/src/internal/poll/fd_unix.go:165
    #	0x158817	net.(*netFD).Read+0x27					/localdata/linuxbrew/.linuxbrew/Cellar/go/1.25.3/libexec/src/net/fd_posix.go:68
    #	0x169053	net.(*conn).Read+0x33					/localdata/linuxbrew/.linuxbrew/Cellar/go/1.25.3/libexec/src/net/net.go:196
    #	0xb9db67	gdcx.com/sfu/gb28181.(*SIPClient).recvLoop+0x117	/home/zpl/src/sfu.work/sfu/gb28181/client.go:522
    #	0xb9d54f	gdcx.com/sfu/gb28181.(*SIPClient).run.func2+0x2f	/home/zpl/src/sfu.work/sfu/gb28181/client.go:398
    
    1 @ 0x8dc70 0x50bc0 0x8ce60 0x107408 0x10b9ec 0x10b9dd 0x15a018 0x172434 0x17148c 0x547e6c 0x547b10 0x1134470 0x11343b5 0x1144f70 0x114a2ac 0x95ce4
    #	0x8ce5f		internal/poll.runtime_pollWait+0x9f		/localdata/linuxbrew/.linuxbrew/Cellar/go/1.25.3/libexec/src/runtime/netpoll.go:351
    #	0x107407	internal/poll.(*pollDesc).wait+0x27		/localdata/linuxbrew/.linuxbrew/Cellar/go/1.25.3/libexec/src/internal/poll/fd_poll_runtime.go:84
    #	0x10b9eb	internal/poll.(*pollDesc).waitRead+0x21b	/localdata/linuxbrew/.linuxbrew/Cellar/go/1.25.3/libexec/src/internal/poll/fd_poll_runtime.go:89
    #	0x10b9dc	internal/poll.(*FD).Accept+0x20c		/localdata/linuxbrew/.linuxbrew/Cellar/go/1.25.3/libexec/src/internal/poll/fd_unix.go:613
    #	0x15a017	net.(*netFD).accept+0x27			/localdata/linuxbrew/.linuxbrew/Cellar/go/1.25.3/libexec/src/net/fd_unix.go:161
    #	0x172433	net.(*TCPListener).accept+0x23			/localdata/linuxbrew/.linuxbrew/Cellar/go/1.25.3/libexec/src/net/tcpsock_posix.go:159
    #	0x17148b	net.(*TCPListener).Accept+0x2b			/localdata/linuxbrew/.linuxbrew/Cellar/go/1.25.3/libexec/src/net/tcpsock.go:380
    #	0x547e6b	net/http.(*Server).Serve+0x24b			/localdata/linuxbrew/.linuxbrew/Cellar/go/1.25.3/libexec/src/net/http/server.go:3463
    #	0x547b0f	net/http.(*Server).ListenAndServe+0x7f		/localdata/linuxbrew/.linuxbrew/Cellar/go/1.25.3/libexec/src/net/http/server.go:3389
    #	0x113446f	net/http.ListenAndServe+0x1ff			/localdata/linuxbrew/.linuxbrew/Cellar/go/1.25.3/libexec/src/net/http/server.go:3704
    #	0x11343b4	github.com/gin-gonic/gin.(*Engine).Run+0x144	/home/zpl/go/pkg/mod/github.com/gin-gonic/[email protected]/gin.go:540
    #	0x1144f6f	gdcx.com/sfu/rest.(*Rest).Start+0x82f		/home/zpl/src/sfu.work/sfu/rest/http.go:190
    #	0x114a2ab	main.main.func4+0x6b				/home/zpl/src/sfu.work/sfu/main.go:270
    
    1 @ 0x8dc70 0x50bc0 0x8ce60 0x107408 0x159ab8 0x159aa5 0x159ab9 0x16e29c 0x16dec0 0x163e44 0x172064 0x171f5c 0x171f5d 0x1504a0 0x14fec4 0x14f828 0x14f304 0x555f08 0x558830 0x5577a4 0x5575a0 0x95ce4
    #	0x8ce5f		internal/poll.runtime_pollWait+0x9f			/localdata/linuxbrew/.linuxbrew/Cellar/go/1.25.3/libexec/src/runtime/netpoll.go:351
    #	0x107407	internal/poll.(*pollDesc).wait+0x27			/localdata/linuxbrew/.linuxbrew/Cellar/go/1.25.3/libexec/src/internal/poll/fd_poll_runtime.go:84
    #	0x159ab7	internal/poll.(*pollDesc).waitWrite+0x4c7		/localdata/linuxbrew/.linuxbrew/Cellar/go/1.25.3/libexec/src/internal/poll/fd_poll_runtime.go:93
    #	0x159aa4	internal/poll.(*FD).WaitWrite+0x4b4			/localdata/linuxbrew/.linuxbrew/Cellar/go/1.25.3/libexec/src/internal/poll/fd_unix.go:685
    #	0x159ab8	net.(*netFD).connect+0x4c8				/localdata/linuxbrew/.linuxbrew/Cellar/go/1.25.3/libexec/src/net/fd_unix.go:130
    #	0x16e29b	net.(*netFD).dial+0x2fb					/localdata/linuxbrew/.linuxbrew/Cellar/go/1.25.3/libexec/src/net/sock_posix.go:124
    #	0x16debf	net.socket+0x20f					/localdata/linuxbrew/.linuxbrew/Cellar/go/1.25.3/libexec/src/net/sock_posix.go:70
    #	0x163e43	net.internetSocket+0xa3					/localdata/linuxbrew/.linuxbrew/Cellar/go/1.25.3/libexec/src/net/ipsock_posix.go:167
    #	0x172063	net.(*sysDialer).doDialTCPProto+0xa3			/localdata/linuxbrew/.linuxbrew/Cellar/go/1.25.3/libexec/src/net/tcpsock_posix.go:85
    #	0x171f5b	net.(*sysDialer).doDialTCP+0x6b				/localdata/linuxbrew/.linuxbrew/Cellar/go/1.25.3/libexec/src/net/tcpsock_posix.go:75
    #	0x171f5c	net.(*sysDialer).dialTCP+0x6c				/localdata/linuxbrew/.linuxbrew/Cellar/go/1.25.3/libexec/src/net/tcpsock_posix.go:71
    #	0x15049f	net.(*sysDialer).dialSingle+0x2cf			/localdata/linuxbrew/.linuxbrew/Cellar/go/1.25.3/libexec/src/net/dial.go:721
    #	0x14fec3	net.(*sysDialer).dialSerial+0x193			/localdata/linuxbrew/.linuxbrew/Cellar/go/1.25.3/libexec/src/net/dial.go:686
    #	0x14f827	net.(*sysDialer).dialParallel+0x1f7			/localdata/linuxbrew/.linuxbrew/Cellar/go/1.25.3/libexec/src/net/dial.go:587
    #	0x14f303	net.(*Dialer).DialContext+0x503				/localdata/linuxbrew/.linuxbrew/Cellar/go/1.25.3/libexec/src/net/dial.go:578
    #	0x555f07	net/http.(*Transport).dial+0xd7				/localdata/linuxbrew/.linuxbrew/Cellar/go/1.25.3/libexec/src/net/http/transport.go:1278
    #	0x55882f	net/http.(*Transport).dialConn+0x5bf			/localdata/linuxbrew/.linuxbrew/Cellar/go/1.25.3/libexec/src/net/http/transport.go:1783
    #	0x5577a3	net/http.(*Transport).dialConnFor+0x83			/localdata/linuxbrew/.linuxbrew/Cellar/go/1.25.3/libexec/src/net/http/transport.go:1618
    #	0x55759f	net/http.(*Transport).startDialConnForLocked.func1+0x2f	/localdata/linuxbrew/.linuxbrew/Cellar/go/1.25.3/libexec/src/net/http/transport.go:1600
    
    1 @ 0x8dc70 0x6bbfc 0x114b038 0x95ce4
    #	0x114b037	main.(*MQHandler).loopHandle+0xa7	/home/zpl/src/sfu.work/sfu/mqhandler.go:172
    
    1 @ 0x8dc70 0x6bbfc 0x159dd4 0x95ce4
    #	0x159dd3	net.(*netFD).connect.func2+0x63	/localdata/linuxbrew/.linuxbrew/Cellar/go/1.25.3/libexec/src/net/fd_unix.go:107
    
    1 @ 0x8dc70 0x6bbfc 0x556da8 0x552f44 0x560580 0x4faaa8 0x4fa4d8 0x4fc3a0 0xabd314 0xabd309 0xabf38c 0xabdcc4 0x114a414 0x95ce4
    #	0x556da7	net/http.(*Transport).getConn+0x317		/localdata/linuxbrew/.linuxbrew/Cellar/go/1.25.3/libexec/src/net/http/transport.go:1523
    #	0x552f43	net/http.(*Transport).roundTrip+0x793		/localdata/linuxbrew/.linuxbrew/Cellar/go/1.25.3/libexec/src/net/http/transport.go:685
    #	0x56057f	net/http.(*Transport).RoundTrip+0x1f		/localdata/linuxbrew/.linuxbrew/Cellar/go/1.25.3/libexec/src/net/http/roundtrip.go:33
    #	0x4faaa7	net/http.send+0x477				/localdata/linuxbrew/.linuxbrew/Cellar/go/1.25.3/libexec/src/net/http/client.go:259
    #	0x4fa4d7	net/http.(*Client).send+0x87			/localdata/linuxbrew/.linuxbrew/Cellar/go/1.25.3/libexec/src/net/http/client.go:180
    #	0x4fc39f	net/http.(*Client).do+0x70f			/localdata/linuxbrew/.linuxbrew/Cellar/go/1.25.3/libexec/src/net/http/client.go:729
    #	0xabd313	net/http.(*Client).Do+0x1a3			/localdata/linuxbrew/.linuxbrew/Cellar/go/1.25.3/libexec/src/net/http/client.go:587
    #	0xabd308	gitee.com/romeo_zpl/infra/util.HttpGet+0x198	/home/zpl/go/pkg/mod/gitee.com/romeo_zpl/[email protected]/util/http.go:92
    #	0xabf38b	gdcx.com/sfu/data.(*dataHttp).retry+0x2ab	/home/zpl/src/sfu.work/sfu/data/data_http.go:252
    #	0xabdcc3	gdcx.com/sfu/data.(*dataHttp).GetSIPServer+0xa3	/home/zpl/src/sfu.work/sfu/data/data_http.go:80
    #	0x114a413	main.main.func1+0x73				/home/zpl/src/sfu.work/sfu/main.go:208
    
    1 @ 0x8dc70 0x6bbfc 0xb9d140 0x95ce4
    #	0xb9d13f	gdcx.com/sfu/gb28181.(*SIPClient).run+0x48f	/home/zpl/src/sfu.work/sfu/gb28181/client.go:406
    
    1 @ 0x8dc70 0x91e10 0x5edcac 0x95ce4
    #	0x91e0f		time.Sleep+0x14f							/localdata/linuxbrew/.linuxbrew/Cellar/go/1.25.3/libexec/src/runtime/time.go:363
    #	0x5edcab	github.com/pion/ion-sfu/pkg/sfu.(*SessionLocal).audioLevelObserver+0x8b	/home/zpl/src/sfu.work/ion-sfu/pkg/sfu/session.go:385
    
    1 @ 0x8dc70 0x91e10 0xad2670 0xad35b8 0x95ce4
    #	0x91e0f		time.Sleep+0x14f									/localdata/linuxbrew/.linuxbrew/Cellar/go/1.25.3/libexec/src/runtime/time.go:363
    #	0xad266f	github.com/eclipse/paho%2emqtt%2egolang.(*backoffController).sleepWithBackoff+0x2f	/home/zpl/go/pkg/mod/github.com/eclipse/[email protected]/backoff.go:101
    #	0xad35b7	github.com/eclipse/paho%2emqtt%2egolang.(*client).reconnect+0x227			/home/zpl/go/pkg/mod/github.com/eclipse/[email protected]/client.go:332

    Image

  29. tubzby commented on Dec 25, 2025

    @tubzby
    Author

    With the help of AI, finally I have figured out that the problem was caused by mis-management of PeerConnection, in my case:

    1. ion-sfu: tubzby/ion-sfu@14ce1cf, the fix is temporary, need more polish.
    2. Some ion-sfu.Peers were not closed.

    If anyone still has this kind of problem, I'll suggest add runtime.AddCleanup to debug alloc/collect event of PeerConnection if you can.

    We just happend to be here because this repo allocates the most amount of memory :)

  30. JoTurk commented on Dec 25, 2025

    @JoTurk
    Member

    great news, glad you were able to find your issue, yeah we tried hard to find anything in Pion :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions