Need a way to unload previously selected TabPage to release USER Objects
up vote
0
down vote
favorite
I have a C# WinForms TabControl, with many controls on each tab page. When you start, not many user objects are loaded, but as you switch tabs, it seems to load the tab with controls, and USER objects grows and grows, eventually hitting the limit and crashing the program. USER Objects is at its max setting in windows. At the moment, it can't be radically redesigned to use less controls, so that is a requirement here to maintain the same amount of controls on each tab.
I'm trying to see if there is a way to after switching tabs, to actually force unload the previous tab, so that it releases its user objects, then if switching back to that tab, everything seems normal and loads that one again (and unloads the previous one). Or some way to mimic this which actually releases USER objects.
I made a test program showing the issue, which can be easily recreated. C# WinForms, added 72 text boxes on each tab. When you start up to Tab 1, Task Manager shows 94 User Objects. When I click Tab 2, it shows 168. They never go lower. This happens without adding anything extra, no events, etc. Adding 2 more tabs, it goes to 315. So this is definitely something going on that is never unloaded, but only after click to tab. I need to find a way to lower USER objects on non-used tabs.
c# .net winforms tabcontrol
|
show 2 more comments
up vote
0
down vote
favorite
I have a C# WinForms TabControl, with many controls on each tab page. When you start, not many user objects are loaded, but as you switch tabs, it seems to load the tab with controls, and USER objects grows and grows, eventually hitting the limit and crashing the program. USER Objects is at its max setting in windows. At the moment, it can't be radically redesigned to use less controls, so that is a requirement here to maintain the same amount of controls on each tab.
I'm trying to see if there is a way to after switching tabs, to actually force unload the previous tab, so that it releases its user objects, then if switching back to that tab, everything seems normal and loads that one again (and unloads the previous one). Or some way to mimic this which actually releases USER objects.
I made a test program showing the issue, which can be easily recreated. C# WinForms, added 72 text boxes on each tab. When you start up to Tab 1, Task Manager shows 94 User Objects. When I click Tab 2, it shows 168. They never go lower. This happens without adding anything extra, no events, etc. Adding 2 more tabs, it goes to 315. So this is definitely something going on that is never unloaded, but only after click to tab. I need to find a way to lower USER objects on non-used tabs.
c# .net winforms tabcontrol
I think normally all tab content is initialized up front... are you dynamically loading content using an event handler when you change tabs? If you post some code, you will get a better answer.
– Elemental Pete
Nov 7 at 16:46
Your program crashes when you created 10,000 controls. That is an enormous number, a tabcontrol with that many of them stopped being usable a long time ago. Crystal ball says that the real problem is that you remove controls with Controls.Clear() or Controls.Remove(). Which is incorrect, you must call their Dispose() method when you do this. Get rid of an entire tab with all its controls by calling the TabPage.Dispose() method.
– Hans Passant
Nov 7 at 16:49
It's not 10,000 (actually it's set to 18,000), it's much less, some controls are really multiple controls, etc or use more than one user object by default. I didn't think it would add on tab switch, but I will investigate and see if there is something causing many additional user objects that can be removed on tab switch. Will write a little test program to see if I can recreate, didn't realize all tabs were preloaded. I wonder if there is a good way to profile what controls creates user objects in Visual Studio.
– Mary Ellen Bench
Nov 7 at 17:25
I made a test program showing the issue. C# WinForms, added 72 text boxes on each tab. When you start up to Tab 1, Task Manager shows 94 User Objects. When I click Tab 2, it shows 168. They never go lower. So does this help anyone with my question? This happens without adding anything extra, no events, etc. Adding 2 more tabs, it goes to 315 only after clicking all tabs. So this is definitely something going on that is never unloaded, but only after click to tab.
– Mary Ellen Bench
Nov 7 at 17:32
1
So you need to "dispose" the controls when the tab is de-selected, but put them back (with their events) when the tab is re-selected. I guess you can try to move all the tab content into a UserControl, then dispose and add the control during those tab events.
– LarsTech
Nov 7 at 18:17
|
show 2 more comments
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have a C# WinForms TabControl, with many controls on each tab page. When you start, not many user objects are loaded, but as you switch tabs, it seems to load the tab with controls, and USER objects grows and grows, eventually hitting the limit and crashing the program. USER Objects is at its max setting in windows. At the moment, it can't be radically redesigned to use less controls, so that is a requirement here to maintain the same amount of controls on each tab.
I'm trying to see if there is a way to after switching tabs, to actually force unload the previous tab, so that it releases its user objects, then if switching back to that tab, everything seems normal and loads that one again (and unloads the previous one). Or some way to mimic this which actually releases USER objects.
I made a test program showing the issue, which can be easily recreated. C# WinForms, added 72 text boxes on each tab. When you start up to Tab 1, Task Manager shows 94 User Objects. When I click Tab 2, it shows 168. They never go lower. This happens without adding anything extra, no events, etc. Adding 2 more tabs, it goes to 315. So this is definitely something going on that is never unloaded, but only after click to tab. I need to find a way to lower USER objects on non-used tabs.
c# .net winforms tabcontrol
I have a C# WinForms TabControl, with many controls on each tab page. When you start, not many user objects are loaded, but as you switch tabs, it seems to load the tab with controls, and USER objects grows and grows, eventually hitting the limit and crashing the program. USER Objects is at its max setting in windows. At the moment, it can't be radically redesigned to use less controls, so that is a requirement here to maintain the same amount of controls on each tab.
I'm trying to see if there is a way to after switching tabs, to actually force unload the previous tab, so that it releases its user objects, then if switching back to that tab, everything seems normal and loads that one again (and unloads the previous one). Or some way to mimic this which actually releases USER objects.
I made a test program showing the issue, which can be easily recreated. C# WinForms, added 72 text boxes on each tab. When you start up to Tab 1, Task Manager shows 94 User Objects. When I click Tab 2, it shows 168. They never go lower. This happens without adding anything extra, no events, etc. Adding 2 more tabs, it goes to 315. So this is definitely something going on that is never unloaded, but only after click to tab. I need to find a way to lower USER objects on non-used tabs.
c# .net winforms tabcontrol
c# .net winforms tabcontrol
edited Nov 7 at 17:35
asked Nov 7 at 16:44
Mary Ellen Bench
1691221
1691221
I think normally all tab content is initialized up front... are you dynamically loading content using an event handler when you change tabs? If you post some code, you will get a better answer.
– Elemental Pete
Nov 7 at 16:46
Your program crashes when you created 10,000 controls. That is an enormous number, a tabcontrol with that many of them stopped being usable a long time ago. Crystal ball says that the real problem is that you remove controls with Controls.Clear() or Controls.Remove(). Which is incorrect, you must call their Dispose() method when you do this. Get rid of an entire tab with all its controls by calling the TabPage.Dispose() method.
– Hans Passant
Nov 7 at 16:49
It's not 10,000 (actually it's set to 18,000), it's much less, some controls are really multiple controls, etc or use more than one user object by default. I didn't think it would add on tab switch, but I will investigate and see if there is something causing many additional user objects that can be removed on tab switch. Will write a little test program to see if I can recreate, didn't realize all tabs were preloaded. I wonder if there is a good way to profile what controls creates user objects in Visual Studio.
– Mary Ellen Bench
Nov 7 at 17:25
I made a test program showing the issue. C# WinForms, added 72 text boxes on each tab. When you start up to Tab 1, Task Manager shows 94 User Objects. When I click Tab 2, it shows 168. They never go lower. So does this help anyone with my question? This happens without adding anything extra, no events, etc. Adding 2 more tabs, it goes to 315 only after clicking all tabs. So this is definitely something going on that is never unloaded, but only after click to tab.
– Mary Ellen Bench
Nov 7 at 17:32
1
So you need to "dispose" the controls when the tab is de-selected, but put them back (with their events) when the tab is re-selected. I guess you can try to move all the tab content into a UserControl, then dispose and add the control during those tab events.
– LarsTech
Nov 7 at 18:17
|
show 2 more comments
I think normally all tab content is initialized up front... are you dynamically loading content using an event handler when you change tabs? If you post some code, you will get a better answer.
– Elemental Pete
Nov 7 at 16:46
Your program crashes when you created 10,000 controls. That is an enormous number, a tabcontrol with that many of them stopped being usable a long time ago. Crystal ball says that the real problem is that you remove controls with Controls.Clear() or Controls.Remove(). Which is incorrect, you must call their Dispose() method when you do this. Get rid of an entire tab with all its controls by calling the TabPage.Dispose() method.
– Hans Passant
Nov 7 at 16:49
It's not 10,000 (actually it's set to 18,000), it's much less, some controls are really multiple controls, etc or use more than one user object by default. I didn't think it would add on tab switch, but I will investigate and see if there is something causing many additional user objects that can be removed on tab switch. Will write a little test program to see if I can recreate, didn't realize all tabs were preloaded. I wonder if there is a good way to profile what controls creates user objects in Visual Studio.
– Mary Ellen Bench
Nov 7 at 17:25
I made a test program showing the issue. C# WinForms, added 72 text boxes on each tab. When you start up to Tab 1, Task Manager shows 94 User Objects. When I click Tab 2, it shows 168. They never go lower. So does this help anyone with my question? This happens without adding anything extra, no events, etc. Adding 2 more tabs, it goes to 315 only after clicking all tabs. So this is definitely something going on that is never unloaded, but only after click to tab.
– Mary Ellen Bench
Nov 7 at 17:32
1
So you need to "dispose" the controls when the tab is de-selected, but put them back (with their events) when the tab is re-selected. I guess you can try to move all the tab content into a UserControl, then dispose and add the control during those tab events.
– LarsTech
Nov 7 at 18:17
I think normally all tab content is initialized up front... are you dynamically loading content using an event handler when you change tabs? If you post some code, you will get a better answer.
– Elemental Pete
Nov 7 at 16:46
I think normally all tab content is initialized up front... are you dynamically loading content using an event handler when you change tabs? If you post some code, you will get a better answer.
– Elemental Pete
Nov 7 at 16:46
Your program crashes when you created 10,000 controls. That is an enormous number, a tabcontrol with that many of them stopped being usable a long time ago. Crystal ball says that the real problem is that you remove controls with Controls.Clear() or Controls.Remove(). Which is incorrect, you must call their Dispose() method when you do this. Get rid of an entire tab with all its controls by calling the TabPage.Dispose() method.
– Hans Passant
Nov 7 at 16:49
Your program crashes when you created 10,000 controls. That is an enormous number, a tabcontrol with that many of them stopped being usable a long time ago. Crystal ball says that the real problem is that you remove controls with Controls.Clear() or Controls.Remove(). Which is incorrect, you must call their Dispose() method when you do this. Get rid of an entire tab with all its controls by calling the TabPage.Dispose() method.
– Hans Passant
Nov 7 at 16:49
It's not 10,000 (actually it's set to 18,000), it's much less, some controls are really multiple controls, etc or use more than one user object by default. I didn't think it would add on tab switch, but I will investigate and see if there is something causing many additional user objects that can be removed on tab switch. Will write a little test program to see if I can recreate, didn't realize all tabs were preloaded. I wonder if there is a good way to profile what controls creates user objects in Visual Studio.
– Mary Ellen Bench
Nov 7 at 17:25
It's not 10,000 (actually it's set to 18,000), it's much less, some controls are really multiple controls, etc or use more than one user object by default. I didn't think it would add on tab switch, but I will investigate and see if there is something causing many additional user objects that can be removed on tab switch. Will write a little test program to see if I can recreate, didn't realize all tabs were preloaded. I wonder if there is a good way to profile what controls creates user objects in Visual Studio.
– Mary Ellen Bench
Nov 7 at 17:25
I made a test program showing the issue. C# WinForms, added 72 text boxes on each tab. When you start up to Tab 1, Task Manager shows 94 User Objects. When I click Tab 2, it shows 168. They never go lower. So does this help anyone with my question? This happens without adding anything extra, no events, etc. Adding 2 more tabs, it goes to 315 only after clicking all tabs. So this is definitely something going on that is never unloaded, but only after click to tab.
– Mary Ellen Bench
Nov 7 at 17:32
I made a test program showing the issue. C# WinForms, added 72 text boxes on each tab. When you start up to Tab 1, Task Manager shows 94 User Objects. When I click Tab 2, it shows 168. They never go lower. So does this help anyone with my question? This happens without adding anything extra, no events, etc. Adding 2 more tabs, it goes to 315 only after clicking all tabs. So this is definitely something going on that is never unloaded, but only after click to tab.
– Mary Ellen Bench
Nov 7 at 17:32
1
1
So you need to "dispose" the controls when the tab is de-selected, but put them back (with their events) when the tab is re-selected. I guess you can try to move all the tab content into a UserControl, then dispose and add the control during those tab events.
– LarsTech
Nov 7 at 18:17
So you need to "dispose" the controls when the tab is de-selected, but put them back (with their events) when the tab is re-selected. I guess you can try to move all the tab content into a UserControl, then dispose and add the control during those tab events.
– LarsTech
Nov 7 at 18:17
|
show 2 more comments
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53194026%2fneed-a-way-to-unload-previously-selected-tabpage-to-release-user-objects%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
I think normally all tab content is initialized up front... are you dynamically loading content using an event handler when you change tabs? If you post some code, you will get a better answer.
– Elemental Pete
Nov 7 at 16:46
Your program crashes when you created 10,000 controls. That is an enormous number, a tabcontrol with that many of them stopped being usable a long time ago. Crystal ball says that the real problem is that you remove controls with Controls.Clear() or Controls.Remove(). Which is incorrect, you must call their Dispose() method when you do this. Get rid of an entire tab with all its controls by calling the TabPage.Dispose() method.
– Hans Passant
Nov 7 at 16:49
It's not 10,000 (actually it's set to 18,000), it's much less, some controls are really multiple controls, etc or use more than one user object by default. I didn't think it would add on tab switch, but I will investigate and see if there is something causing many additional user objects that can be removed on tab switch. Will write a little test program to see if I can recreate, didn't realize all tabs were preloaded. I wonder if there is a good way to profile what controls creates user objects in Visual Studio.
– Mary Ellen Bench
Nov 7 at 17:25
I made a test program showing the issue. C# WinForms, added 72 text boxes on each tab. When you start up to Tab 1, Task Manager shows 94 User Objects. When I click Tab 2, it shows 168. They never go lower. So does this help anyone with my question? This happens without adding anything extra, no events, etc. Adding 2 more tabs, it goes to 315 only after clicking all tabs. So this is definitely something going on that is never unloaded, but only after click to tab.
– Mary Ellen Bench
Nov 7 at 17:32
1
So you need to "dispose" the controls when the tab is de-selected, but put them back (with their events) when the tab is re-selected. I guess you can try to move all the tab content into a UserControl, then dispose and add the control during those tab events.
– LarsTech
Nov 7 at 18:17