0

I have a windows form which have a textbox & a button on it. I'll show & use this form for filtering some datagrid columns when right clicked their column header. And this form will be using constantly obviously. Now I'm thinking, Should I close it everytime or simply hide & reshow when needed? Which is the best for performance & memory? Or do you suggest any other thing for this filtering type?

mimozz
  • 94
  • 1
  • 9
  • Related: http://stackoverflow.com/questions/440051/is-it-possible-to-reuse-a-net-winforms-form-object – Konamiman Jun 09 '15 at 09:59
  • 1
    It's a form. It's not like you're transcoding video in real-time. Performance and memory is going to be such a non-event that it's really not worth worrying about. If I were you, with all due respect, I would move on with whatever gets you paid. – Enigmativity Jun 09 '15 at 10:02
  • 1
    @Enigmativity if it's a form the user frequently needs, and it takes more than a fraction of a second to load, I'd opt for letting it stay in memory. Database access is expensive, even more so when it's unnecessary. :) – CodeCaster Jun 09 '15 at 10:05

2 Answers2

3

Which is the best for performance & memory?

"Best" isn't a question nor a SMART requirement.

Of course if you just hide the form, it and its contents will stay in memory. This means your application uses more memory, but on the other hand, when you need to show the form again, you won't have to load the entries from the database again - making it appear faster.

If it's a form you really frequently need, I'd just hide and re-show it. See Hide form instead of closing when close button clicked how to do this.

Community
  • 1
  • 1
CodeCaster
  • 147,647
  • 23
  • 218
  • 272
0

If the app runs very fast, it may be better to close it. If loading is heavy - hide it.

i486
  • 6,491
  • 4
  • 24
  • 41