-
Notifications
You must be signed in to change notification settings - Fork 1.1k
内存泄露问题修复 #4779
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
base: develop
Are you sure you want to change the base?
内存泄露问题修复 #4779
Conversation
scyyh11
commented
Nov 28, 2025
- 使用 cv2.imencode 优化图像编码,降低内存占用。
- 增加 malloc_trim 强制回收内存碎片。
- 增加显式 GC 和对象删除逻辑。
2. 增加 malloc_trim 强制回收内存碎片。 3. 增加显式 GC 和对象删除逻辑。
|
Thanks for your contribution! |
Bobholamovic
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
感谢贡献!我留了一些评论,请看看。
| elif isinstance(image, np.ndarray): | ||
| import cv2 | ||
|
|
||
| success, buffer = cv2.imencode('.jpg', image, [int(cv2.IMWRITE_JPEG_QUALITY), 95]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
此前发现cv2.imencode与PIL.Image.save存在区别,这样做似乎会影响精度。可能需要确认一下换用cv2.imencode的必要性。
| result = future.result() | ||
| results.append(result.choices[0].message.content) | ||
|
|
||
| _force_memory_compact() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
在每次执行完成后调用gc.collect,是否影响推理速度?
| gc.collect() | ||
| if platform.system() == "Linux": | ||
| try: | ||
| libc = ctypes.CDLL("libc.so.6") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里硬编码了库名。是否可以采用更通用的方法(例如ctypes.util.find_library)?