¿ªÔÆÌåÓý

ctrl + shift + ? for shortcuts
© 2025 Groups.io

Re: IB Gateway Memory Leak?


 

¿ªÔÆÌåÓý

Since the IB Gateway is Java-based, it seems that the only way it would accumulate a lot of memory would be if the messages that it sends are not immediately released after being received by the reader.? I suspect that they optimized the gateway for responsiveness and defer garbage collection to prioritize responsiveness.? Since I occasionally use the Gateway to pull strikes and expirations once every week or two on a list of about 500 stocks and ETFs, it stays busy for a while...but still, it shouldn't take that long to do garbage collection and seems that they could use a parallel garbage collector.? In any case, I worked around my issue for now by just giving it a lot of memory.? Just curious if there was an additional call I was supposed to make to cause the gateway to release messages / free up memory.? I think TWS and Gateway offer a lot of good features.? Definitely think Java was the right language choice in order to make it cross-platform.? But as a Java developer, it just feels a lot slower and bloated than it should be.? I think the codebase could be cleaned up a lot and made to run a lot faster and more efficient.


From: [email protected] <[email protected]> on behalf of Matthias Frener <matthias.frener@...>
Sent: Wednesday, June 23, 2021 1:57 AM
To: [email protected] <[email protected]>
Subject: Re: [TWS API] IB Gateway Memory Leak?
?

Had a similar issue on my App when starting up the watchlists (I request a whole bunch of market data within a short period of time).
What I have noticed, is that there is strong relation between memory consumption on how many request you do within a certain amount of time. Not sure yet if really leaks memory (always difficult to say from outside what GC actually does), or if Gateway process is just busy to do garbage collection and so you pile up memory until there is now more.
Don't know if this solution is any helpful for you, but I have solved it by further decreasing rate limit.
I use the Typescript Api () where we have a rate-limiter on the send-thread to enforce the max 50 request/second limit. If have further reduced this to 25req/s and increased Gateway Memory limit to 1GB. Works fine since then. Maybe try to stretch out the requests over time if possible - don't try to get all all strikes on 3 dates simulations, but do 1 by 1, trying to keep as pressure to Gateway as low as possible.

Join [email protected] to automatically receive all group messages.