Hi When I deploy my project, I see RAM monotonically climbs by around 2mb every 3s. Once it reaches around 530MB/512MB, it lowers itself to around 240MB/512MB and repeats. Is this a memory leak? I'm not receiving an error though.
Any advice appreciated.
John Munro
I should mention this is the issue when paper trading.
Mia Alissi
Based on the information provided in the extracts, it's not clear if the memory usage pattern you're observing is due to a memory leak or is a normal part of the operation of the paper trading system.
In one of the forum discussions, a user mentioned a similar issue where the garbage collector could not allocate memory, and the suggestion was to try running the strategy with fewer securities (source). This might be worth trying in your case as well.
If you're using the QuantConnect Paper Trading system, it's designed to simulate trades using fictional capital, allowing you to test your algorithm without risking real money (source). However, if you're handling a large amount of data or a large number of securities, it could potentially lead to high memory usage.
If the issue persists, it would be best to reach out to the QuantConnect community or support for more specific guidance.
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
Jared Broad
I wouldn't worry about it until the project is shutdown or the garbage collection is unsuccessful at reducing the usage. LEAN is designed to consume as much memory as its allowed for speed.Â
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
Ethan Hammond
Jared Broad , I am running into the same issue listed above. I'm using LiveNodePacket().RamAllocation to manually monitor RAM usage, and I am also seeing incremental increases in usage. Unlike John Munro , my RAM reaches 700+MB/512MB before collecting.
I've tried manual collection using gc.collect(). However, this has not yielded any immediate reductions in RAM usage. There are certain points in the algorithm that would benefit from a manual RAM collection. Is this possible? As Mia Alissi mentioned, I have reduced the number of securities in the universe to less than 50, so I should not be exceeding the 512MB RAM limit. However, I continue to get memory errors at certain locations in the algorithm.
Mia Alissi
Based on the information provided in the extracts, it seems like you're encountering a memory issue despite reducing the number of securities in your universe.
In one of the forum discussions, a user mentioned a similar issue where the garbage collector could not allocate memory, and the suggestion was to try running the strategy with fewer securities (source). You've already tried this solution, but it seems the issue persists.
As for manually collecting RAM, it's important to note that the garbage collector in .NET (which LEAN uses) operates on its own schedule and it might not immediately free up memory when
gc.collect()
is called.In another discussion, it was mentioned that securities are never removed from the collection in the algorithm, which is a known, intentional behavior. They have a relatively small impact so it doesn't slow the algorithm down (source). This might be contributing to the memory usage you're observing.
If the issue continues, it would be best to reach out to the QuantConnect community or support for more specific guidance. They might be able to provide more insights into the memory management of LEAN and how to optimize your algorithm to avoid exceeding the RAM limit.
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
Jared Broad
Hi @Ethan, please attach a project for assistance or send a support ticket to private support. If you're scanning more than 100 securities, we recommend a larger node. We estimate roughly 5-10MB RAM per asset.Â
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
BoboStone
What is the resolution you are referring to? Do we expect 5-10MB RAM per asset under `Resolution.Daily`?
John Munro
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!