Comments (6)
Well, my tests if you mean how I detect memory leak, I just check the docker container after a week of runtime
What code I run is this:
https://github.com/bitcartcc/bitcart/blob/master/daemons/trx.py
If you want to try testing it (I really appreciate), you can do the following:
git clone https://github.com/bitcartcc/bitcart
cd bitcart
pip install -r requirements/base.txt
pip install -r requirements/daemons/trx.py # installs tronpy
TRX_SERVER=https://rpc.ankr.com/http/tron TRX_DEBUG=true python3 daemons/trx.py
My suspicion is that tronpy's httpx client has some leak issues, with aiohttp it is way more stable. That's why we use this temporarily: https://github.com/bitcartcc/bitcart/blob/b2f0c014779e8d329f8f476fe58ea00a9d085d3f/daemons/trx.py#L34-L53
Another fix I applied in production is jemalloc to avoid memory fragmentation, but in general the memory usage is still growing. I didn't re-run my profiler to gather flamegraph after the series of fixes I did. jemalloc seems to slow down the memory usage but it still grows. Maybe it's my app now and not tronpy, not sure
I would really appreciate your help (I can even send my contacts for further discussion)
from tronpy.
Confirmed: the library is fine.
In case you think it's a memory leak, note that the place where the leak is supposed to happen isn't always the issue. In my case the flamegraphs shown that all the leaks where in http client code, i.e. tronpy calls to httpx lib. That's actually where memory was allocated and not deallocated. But the real issue in my specific case was maintaining an uncapped list of events for example.
But for production environments an allocator better than built-in malloc would only help. I.e. you can employ jemalloc for example like so:
https://github.com/bitcartcc/bitcart-docker/blob/7c259836275f56f58acc755fbea6984cae0df6af/compose/trx.Dockerfile#L39
The library is good and works well in production environments!
from tronpy.
Hi @MrNaif2018, I saw high memory usage in one of the projects that uses tronpy.
Could you please share your tests, so I'll try to reproduce and understand what's happening
from tronpy.
@abaybek You can contact me via [email protected] or MrNaif_bel at telegram (preferred) if you want to debug this issue together. I've spent a few months on this :D
from tronpy.
I googled and found these might help:
encode/httpx#978
https://bugs.python.org/issue40727
from tronpy.
Yep, I've checked it. But the thing is, we create an async client just once. Though I tested many things and in production it is using aiohttp client + orjson + jemalloc etc, not sure which one contributed to the fix mostly
from tronpy.
Related Issues (20)
- How to calculate "parameter" for "trigger_constant_contract" method? HOT 1
- How can I send usdt with tronpy please help HOT 4
- 403 Client Error HOT 14
- how i send trx with float HOT 2
- network is the test network. Why is the query still about the main network HOT 1
- 'Tron' object has no attribute 'generate_address_with_mnemonic' HOT 1
- LOCK_PERIOD is not included for delegate_resource HOT 6
- getDelegatedResourcev2 not included
- GetDelegatedResourceAccountIndexV2 not included (important) HOT 7
- GetCanDelegatedMaxSize not included HOT 2
- How to perform Estimated energy HOT 1
- Function get_function_by_selector returning None HOT 1
- delegate_resource cannot be used HOT 1
- Dear author, how to monitor the Transfer event of TRC20? HOT 5
- Error while trying to query how much usdt is in a wallet HOT 1
- ABI error when using HTTPProviver over just nile network HOT 2
- delete issue
- Got 403 Forbidden when use AsyncTron HOT 1
- TypeError: provider is not a HTTPProvider when using AsyncHTTPProvider HOT 1
- calculate the bandwidth HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tronpy.