Skip to content
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

此处存在cuda内存泄漏,engine没有调用析构函数,没有销毁 #208

Open
HaronCHou opened this issue Oct 19, 2023 · 2 comments

Comments

@HaronCHou
Copy link

https://github.com/shouxieai/tensorRT_Pro/blob/84c3f6894bfdc5d7c3c3a48044f0437936d4fb14/example-simple_yolo/src/simple_yolo.cu#L1841C20-L1841C20

需要在Engine Destroy的打印信息之前加上 engine.reset()才能成功将申请的CudaStream给释放掉;这里将造成内存泄漏。

ls -l /proc/进程号/fd 可以观察到内存泄漏!

虽然程序退出后,系统会自动回收句柄,但这里不断的new和delete之后,将造成大量泄漏

@scteam1994
Copy link

为什么这里会不断new engine呢,这个worker我理解是在一个线程里运行的,程序不推出这个worker会一直在while循环里等待job

@HaronCHou
Copy link
Author

为什么这里会不断new engine呢,这个worker我理解是在一个线程里运行的,程序不推出这个worker会一直在while循环里等待job

程序最后退出的时候,没有取访问engine的析构函数,有一部分内存没有释放。

  • 最后发现这问题也解决不了;就是cuda stream这些资源的管理,在主程序没退出的时候,还是一直存在,所以只能不管了。
  • 你强行退出的话,反而会不断的new。cuda对资源管理的问题吧,我也搞不懂了。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants