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

KT built for Win10/11 is possibly leaking memory #138

Open
gfeyer opened this issue Feb 17, 2023 · 3 comments
Open

KT built for Win10/11 is possibly leaking memory #138

gfeyer opened this issue Feb 17, 2023 · 3 comments

Comments

@gfeyer
Copy link

gfeyer commented Feb 17, 2023

Hi guys!

Summary:
I'm using KT extensively on macos/linux/windows and it works great for linux and mac.
The issue is that the windows kt.exe build is leaking memory.

How to reproduce:
in Win10/11, in main repo, do a standard go build. This generates kt.exe

in cmd prompt:
kt.exe -brokers ip:port -offsets all=newest -topic topic_name

In task manager, monitor kt.exe and memory is increasing linearly, as-if all the data that is consumed from the topic is loaded into RAM and not released. It starts around 15MB and keeps on growing into the hundreds of MB

Notes:
On Ubuntu Linux and macOS the RAM usage is stable at 26MB

Any thoughts on this? I compiled with latest go version and tested on both Windows10 and Windows11.

Thanks in advance for any insights!
Best regards,

@gfeyer
Copy link
Author

gfeyer commented Feb 19, 2023

Adding more info:
I've let this run until it reached about 200MB when the GC started to kick in with very large "stop the world" pauses. Consuming from the stream is stopping for 200-500ms at a time every couple of seconds, though the memory did start to go down.
Waiting for a while it stabilizes around 100MB RAM but it has large increases in RAM every second putting a large strain on the GC to bring it back down and stopping the app every couple of seconds for the cleanup.
Any ideas?
Thanks in advance

@gfeyer
Copy link
Author

gfeyer commented Feb 19, 2023

I ran a profiler on KT and it's actually coming from the underlying sarama library. I'll continue to trace it in Sarama. Thanks.
For future reference:

github.com/Shopify/sarama.(*Broker).responseReceiver
N:\go\pkg\mod\github.com\!shopify\[email protected]\broker.go

  Total:     43.40MB    43.40MB (flat, cum) 84.37%
   1152            .          .           			dead = PacketDecodingError{fmt.Sprintf("correlation ID didn't match, wanted %d, got %d", response.correlationID, decodedHeader.correlationID)} 
   1153            .          .           			response.handle(nil, dead) 
   1154            .          .           			continue 
   1155            .          .           		} 
   1156            .          .            
   1157      43.40MB    43.40MB           		buf := make([]byte, decodedHeader.length-int32(headerLength)+4) 
   1158            .          .           		bytesReadBody, err := b.readFull(buf) 
   1159            .          .           		b.updateIncomingCommunicationMetrics(bytesReadHeader+bytesReadBody, requestLatency) 
   1160            .          .           		if err != nil { 
   1161            .          .           			dead = err 
   1162            .          .           			response.handle(nil, err) 

@fgeller
Copy link
Owner

fgeller commented Mar 9, 2023

sorry for the delay, but 🎉 that you figured it out :) let me know if it'd help to upgrade sarama or bring a fix in somehow

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants