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
[BUG] Memory Leak Warning #341
Comments
Hey @ayush-mehta, Please provide a minimal reproducible example. Louis |
I have multiple files, I'll start sharing them in this thread for reproducing |
Here is my utils/graphing.py file
|
Here is my service/webhook.py file
|
And here is my outer most file which I am running, which imports the function from the webhook.py file
|
Hey, That is not a minimal reproducible example. Use Louis |
Hey @louisnw01,
After many such code executions and warnings, it gives following error, to fix it I restart my device and then it starts working but with the warnings. I'll go through. your examples and share the minimal reproducible example soon |
Here is the minimal reproducible example @louisnw01 , csv file is not needed as I am fetching data from yfinance, it returns a dataframe. I hope that this helps you reproduce the issue.
|
Other than the message, I'm not getting any unexpected behaviour |
The semaphore object message has been on my radar for a while now, but I haven't been able to find a fix. If I do I will push a hotfix, but it doesn't appear to be causing anything strange to happen. |
I'm also facing the same issue, At first I also got the similar warning but after weeks of daily execution I got |
At first it does not cause any strange behaviour, but upon multiple executions, it starts eating space on the device, you can yourself check it, try running the same file for couple of hundreds of time, and you'll see a jump in the memory, and once it reaches above a certain threshold, you'll start getting There is somewhere a memory leak in the service, which I am unable to debug. Have you tried running profilers to find the leak @louisnw01 ? |
@ayush-mehta I had the same issue before, also while taking screenshots of charts in quick succession. While I wasn't able to fully pin down the root cause, it did go away for me. Two things that may have done it:
|
Hey @bent-verbiage |
Sorry to hear that @ayush-mehta. I'm no expert but just in case it helps, see the code that I use below. Some of the retry and exception handling is possibly overkill, but once I stopped getting the errors, I left it as it was. Obviously @louisnw01 is the authority though, and hopefully can find the root cause. And maybe even a way to capture screenshots that include the subcharts :-)
|
@bent-verbiage I tried your approach, I have attached my snippet below, but I am still getting warning of leaked semaphore objects. I even tried commenting out the screenshot segment. Do you get the similar warning message, if not then it could be device or processor specific issue which is bit unlikely. Try running the following snippet and let us know. I believe the issue is with the chart object itself, the python garbage collector is somehow unable to free up the space. I even tried, to invoke garbage collector using @louisnw01 it'd be great help if you could share me code documentation which contains LLD of this library. I went through the documentation attached but I believe it is not sufficient for developers to understand and start contributing easily.
|
@ayush-mehta As for LLD, I haven't provided this as of yet but will look to once v2.0 is released. The code which will be the culprit is located in I do remember this warning did not always show up, so perhaps looking back at older versions until you reach one which doesn't throw the warning might be of use? |
@louisnw01 I'll try going through the previous versions and figure out a cause, this information is really helpful and will ease things up a bit for me. |
Question
I am importing a class Chart() whose object I am creating in my code
Someone raised a github issue with similar issue, there @louisnw01 replied that You must encapsulate the Chart object within an if name == 'main' block.
Now I'll explain what my code is doing
Inside the if name == 'main' block, I am invoking an async function using asyncio.run(main())
Now Inside the main, I am awaiting another async function called processMessage which is written in another file, and inside that processMessage Function I am invoking another function called createChart which is again in another file which is creating the Chart object and it returns the screenshot in bytes array.
I am not sure what I am doing wrong I even tried to delete the chart object which I created from Chart class
This is where I am creating Chart object
I am invoking this function through another function which is called insides if name=='main' block, I am not sure how to fix it
The text was updated successfully, but these errors were encountered: