C
C#6mo ago
Mazranel

Memory leaks with OpenFileDIalog, SaveFIleDialog, and DataGridView in WinForms

Hello! I'm noticing memory leaks when doing the following: * using OpenFileDialog or SaveFileDialog, even inside using * Adding new rows to a DataGridView (seems like clearing the table doesn't free anything?) I've been researching for a few hours now and haven't come across any solutions yet. Does anyone know what could be going on? I've attached some code examples that should give more details.
No description
No description
No description
9 Replies
Unknown User
Unknown User6mo ago
Message Not Public
Sign In & Join Server To View
Mazranel
MazranelOP6mo ago
My application's memory usage would increase from 30 to 47mb, and wouldn't go back down once the dialog was closed. The memory usage would continue to increase every time the dialog is opened. Also, adding a lot of rows to the DataGridView would have the same results As for tools, I only used VS 2022's memory usage chart and task manager The memory usage kept climbing and would not go back down, even when calling GC.Collect
canton7
canton76mo ago
I mean, 47mb isn't a lot. The runtime will happily allocate that much if it needs to at some point, and it won't bother giving it back to the OS unless the OS asks for it
Unknown User
Unknown User6mo ago
Message Not Public
Sign In & Join Server To View
Mazranel
MazranelOP6mo ago
Ah I guess I misunderstood how that would work Is there anything I can do to help mitigate excessive memory usage when loading lots of data into a table? Also, why wouldn't the runtime give the memory back to the OS if it's done using it?
reflectronic
reflectronic6mo ago
what if it wants to use it again then you gave it back just to take it again
Mazranel
MazranelOP6mo ago
ah, right
Unknown User
Unknown User6mo ago
Message Not Public
Sign In & Join Server To View
Mazranel
MazranelOP6mo ago
Yes
Want results from more Discord servers?
Add your server