erijo / transparent-proxy Goto Github PK
View Code? Open in Web Editor NEWA basic transparent HTTP proxy
A basic transparent HTTP proxy
Hello erijo!
I've tried this code but there is a memory leak.
Debug output after one request:
(Pdb) from guppy import hpy
(Pdb) hh = hpy()
(Pdb) before = hh.heap()
(Pdb) after = hh.heap()
(Pdb) delta = after - before
(Pdb) print delta
Partition of a set of 5079 objects. Total size = 521828 bytes.
Index Count % Size % Cumulative % Kind (class / dict of class)
0 409 8 160940 31 160940 31 dict (no owner)
1 2366 47 102748 20 263688 51 str
2 40 1 67040 13 330728 63 dict of main.ProxyRequest
3 928 18 59264 11 389992 75 list
4 40 1 23128 4 413120 79 unicode
5 40 1 20960 4 434080 83 dict of main.ProxyClientFactory
6 40 1 20960 4 455040 87 dict of twisted.internet.tcp.Server
7 80 2 11200 2 466240 89 dict of twisted.internet.address.IPv4Address
8 80 2 11200 2 477440 91 dict of twisted.logger._logger.Logger
9 80 2 11200 2 488640 94 dict of twisted.web.http_headers.Headers
Every request raises count of all this objects and allocates more and more memory.
One more request after:
(Pdb) after = hh.heap()
(Pdb) delta = after - before
(Pdb) print delta
Partition of a set of 10711 objects. Total size = 1104316 bytes.
Index Count % Size % Cumulative % Kind (class / dict of class)
0 852 8 337776 31 337776 31 dict (no owner)
1 4970 46 217372 20 555148 50 str
2 84 1 140784 13 695932 63 dict of main.ProxyRequest
3 1924 18 122960 11 818892 74 list
4 84 1 48528 4 867420 79 unicode
5 84 1 44016 4 911436 83 dict of main.ProxyClientFactory
6 84 1 44016 4 955452 87 dict of twisted.internet.tcp.Server
7 168 2 23520 2 978972 89 dict of twisted.internet.address.IPv4Address
8 168 2 23520 2 1002492 91 dict of twisted.logger.logger.Logger
9 168 2 23520 2 1026012 93 dict of twisted.web.http_headers.Headers
<24 more rows. Type e.g. '.more' to view.>
I've tried to fix it by myself but im not so skilled in Twisted.
Hope you know how to fix it ;)
Best regards.
What is the porpuse of the connection close line in the request that go out to the real server ?
And when i am removing that line , i get exception when i do self.finish() in the clentProxy request.
Can you please elaborate
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.