You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello.
I tried to beautify some javascript data in my python scripts by jsbeautifier.
But the result of it, my program started to use LARGE memory.
Input
The code looked like this before beautification:
for response_content in response_contents:
import jsbeautifier
self.response_contents.append(jsbeautifier.beautify(response_content))
del jsbeautifier # I tried to remove jsbeautifier from memory
print("=================================== check memory")
snapshot = tracemalloc.take_snapshot()
for idx, stat in enumerate(snapshot.statistics('lineno')[:5], 1):
print(str(stat))
traces = tracemalloc.take_snapshot().statistics('traceback')
for stat in traces[:1]:
print("memory_blocks=", stat.count, "size_kB=", stat.size / 1024)
for line in stat.traceback.format():
print(line)
print("=================================== check memory end")
print(f"[__js_beautify] Beautified (len:{len(response_content)})")
Expected Output
The code should have looked like this after beautification:
=================================== check memory
=================================== check memory end
[__js_beautify] Beautified (len:1613161)
I expected it would use less CPU and less memory.
Actual Output
The code actually looked like this after beautification:
=================================== check memory
/usr/lib/python3.8/json/decoder.py:353: size=111 MiB, count=14586, average=7976 B
/usr/local/lib/python3.8/dist-packages/jsbeautifier/core/token.py:28: size=58.0 MiB, count=524189, average=116 B
/usr/local/lib/python3.8/dist-packages/jsbeautifier/core/tokenizer.py:129: size=12.0 MiB, count=262092, average=48 B
<frozen importlib._bootstrap_external>:640: size=9192 KiB, count=56476, average=167 B
/usr/local/lib/python3.8/dist-packages/jsbeautifier/core/output.py:266: size=4005 KiB, count=7, average=572 KiB
('memory_blocks=', 14586, 'size_kB=', 113617.1328125)
File "/usr/lib/python3.8/json/decoder.py", line 353
obj, end = self.scan_once(s, idx)
=================================== check memory end
[__js_beautify] Beautified (len:1613161)
But it started to use a huge amount of memory and a lot of CPU...
I think that it starts to use huge amounts of memory after full CPU usage
Steps to Reproduce
Environment
OS: Ubuntu 20.04 LTS
Python Version: 3.8.10
Settings
FROM ubuntu:20.04
ARG DEBIAN_FRONTEND=noninteractive
COPY ./source/requirements.txt /tmp/requirements.txt
RUN pip3 install -r /tmp/requirements.txt
WORKDIR /usr/share/MyProject
COPY ./source/ ./
COPY ./Entrypoint.sh /Entrypoint.sh
RUN chmod 777 /Entrypoint.sh
ENTRYPOINT ["/Entrypoint.sh"]
The text was updated successfully, but these errors were encountered:
papaya-ais
changed the title
jsbeautifier uses too much memory and never release that
jsbeautifier uses too much memory and never releases that
Nov 5, 2024
Description
Hello.
I tried to beautify some javascript data in my python scripts by jsbeautifier.
But the result of it, my program started to use LARGE memory.
Input
The code looked like this before beautification:
Expected Output
The code should have looked like this after beautification:
I expected it would use less CPU and less memory.
Actual Output
The code actually looked like this after beautification:
But it started to use a huge amount of memory and a lot of CPU...
I think that it starts to use huge amounts of memory after full CPU usage
Steps to Reproduce
Environment
OS: Ubuntu 20.04 LTS
Python Version: 3.8.10
Settings
The text was updated successfully, but these errors were encountered: