Commit ecaa144
authored
Fix a memory "leak" in VisMF's persistent streams (#3592)
## Summary
VisMF uses a std::map to keep track of the streams it opens. Each
PersistentIFStream object also has a vector used as IO buffer. When a
stream is closed, we need to free to memory used by the buffer. The
issue was it used std::vector::clear(), which only changes size()
without reducing capacity() at all. So the memory was never freed. The
issue is now fixed by std::vector::swap.
## Additional background
Thank Simon Guichandut (@simonguichandut) for reporting this! Thank Eric
Johnson (@yut23) for pinning down the location of the leak with the help
of the Massif heap profiler!
## Checklist
The proposed changes:
- [x] fix a bug or incorrect behavior in AMReX
- [ ] add new capabilities to AMReX
- [ ] changes answers in the test suite to more than roundoff level
- [ ] are likely to significantly affect the results of downstream AMReX
users
- [ ] include documentation in the code and/or rst files, if appropriate1 parent 77d4d1f commit ecaa144
2 files changed
+5
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2202 | 2202 | | |
2203 | 2203 | | |
2204 | 2204 | | |
2205 | | - | |
| 2205 | + | |
2206 | 2206 | | |
2207 | 2207 | | |
2208 | 2208 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
32 | 36 | | |
33 | 37 | | |
34 | 38 | | |
| |||
0 commit comments