-
-
Notifications
You must be signed in to change notification settings - Fork 229
Open
Labels
bugSomething isn't workingSomething isn't working
Description
TLS client version
1.8.0
System information
MacBook Pro M3 Pro
macOS 15.3.1
Issue description
When making requests that return large responses, memory usage goes through the roof. It doesn’t seem to scale properly with the response size.
Output
Before request: 15MB
After request: 700MB
Response size: 82MB
After response: 1342MB
After freeMemory: 1342MB
A 82MB response shouldn’t cause memory usage to jump by over 1GB. Some increase is expected, but this seems excessive.
Steps to reproduce / Code Sample
import ctypes
import json
import psutil
def memory_usage():
return psutil.Process().memory_info().rss // (1024 ** 2)
library = ctypes.cdll.LoadLibrary('../lib/tls/tls-client-darwin-arm64-1.8.0.dylib')
# extract the exposed request function from the shared package
request = library.request
request.argtypes = [ctypes.c_char_p]
request.restype = ctypes.c_char_p
freeMemory = library.freeMemory
freeMemory.argtypes = [ctypes.c_char_p]
requestPayload = {
"tlsClientIdentifier": "chrome_105",
"requestUrl": "https://platform.tonybet.com/api/event/list?limit=200&main=0&page=1&oddsExists_eq=1&period=0&lang=en&relations%5B%5D=odds&relations%5B%5D=competitors&relations%5B%5D=players&relations%5B%5D=variants&relations%5B%5D=league&relations%5B%5D=sport",
"requestMethod": "GET",
}
print(f"Before request: {memory_usage()}MB")
response = request(json.dumps(requestPayload).encode('utf-8'))
print(f"After request: {memory_usage()}MB")
response_bytes = ctypes.string_at(response)
response_string = response_bytes.decode('utf-8')
response_object = json.loads(response_string)
print(f"Response size: {len(response_bytes) // (1024 ** 2)}MB")
print(f"After response: {memory_usage()}MB")
freeMemory(response_object['id'].encode('utf-8'))
print(f"After freeMemory: {memory_usage()}MB")Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working