Skip to content

[BugFix] Fix PopenWorker Memory Leak#10874

Closed
zxybazh wants to merge 3 commits intoapache:mainfrom
zxybazh:bugfix/2022-04-01/popen-worker-reader-writer
Closed

[BugFix] Fix PopenWorker Memory Leak#10874
zxybazh wants to merge 3 commits intoapache:mainfrom
zxybazh:bugfix/2022-04-01/popen-worker-reader-writer

Conversation

@zxybazh
Copy link
Member

@zxybazh zxybazh commented Apr 1, 2022

During tuning of meta schedule I found a memory leak from PopenWorker. The cause is related to the use of reader and writer inside of the class. I rewrote the Popenworker to create a new reader / writer before usage. There might slightly impact the overhead of tuning but avoids the memory leak.

CC: @tqchen @junrushao1994 @shingjan

Copy link

@shingjan shingjan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks for sending this fix!


lock = threading.Lock()

def get_reader():
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry that I actually do not fully get why fdopen in a subfunction helps. can you elaborate why? (with an example)

Copy link
Member Author

@zxybazh zxybazh Apr 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi TQ, it does not acutally help that we put fdopen into a subfunction. The cause of the memory leak is acutally reusing the same reader and writer. The change is acutally to create new reader and writer everytime instead of reusing the same ones to avoid leak. After checking the proccess status, I found that this fix does not really fix the problem because it only caused the process to suicide which avoided memory leak.

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

Successfully merging this pull request may close these issues.

4 participants