Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
9and3 committed Aug 16, 2023
2 parents 68b9dae + 188a4db commit 765b41b
Showing 1 changed file with 0 additions and 35 deletions.
35 changes: 0 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -205,38 +205,3 @@ To run the code:

## How to contribute
Please have a look at the `contributing.md" file. There you will find all the set of rules and the main softwarer documentation to contribute.

## 🚧🚧🚧 Memory Leak Issue 🚧🚧🚧
We notice the memory leak caused by TTool integration.
### Cause
- TTool uses Qt5's View to render the track the toolheads.
- AC uses glfw to show window UI.
- Thus, context switching between TTool and AC is required in order for OpenGL to render to the correct buffers.
#### Context Switching
- In order to do the context switching between AC and TTool, we introduced `TTool::MakeCurrent()` and `TTool::ReleaseCurrent()` on TTool.
- We also introduct `Window::MakeCurrent()` and `Window::ReleaseCurrent()` on Window.
- Now, one context needs to be released, before the other can make current.
#### Issues/Behaviours
- We found that the MakeCurrent and ReleaseCurrent cannot be called carelessly.
- In the `Application::Run()`, this make and release will be called repeatedly, which leads to additional memory increase on the program which will not decrease.
#### Replication
- Run this program on this commit, and monitor the memory increase.
- To replicate the worse memory leak rate that we discovered, please change from this commit (d876108cd9cff82dd72c2a1d8be1306c7db3b19a)
```cpp
// Application.cpp

void Application::Run()
{
// ... code before ...
m_Window->MakeCurrent(); // ADD THIS LINE

GetLayer<AIAC::LayerUI>()->OnUIRender();

m_Window->ReleaseCurrent(); // ADD THIS LINE
// ... code after ...
}
}
```
#### Mitigation
- We put the context switching only on the TTool `OnAttach` and `OnFrameStart`.
- In this current commit (d876108cd9cff82dd72c2a1d8be1306c7db3b19a), we found the most bearable memory increase rate, that will allow the program to run for some hours on 10GB memory device.

0 comments on commit 765b41b

Please sign in to comment.