Click here to Skip to main content
15,892,643 members
Please Sign up or sign in to vote.
4.50/5 (2 votes)
See more:
Hi,

HeaderedContentControl's content setting process increases memory usage (Memory Leak)

I am using HeaderedContentControl control in my WPF application.

and I have bound content property to view model property using Data binding.

XML
<HeaderedContentControl HorizontalContentAlignment="Center" FocusVisualStyle="{x:Null}"  Margin="20" Grid.Row="1" Grid.Column="0" Content="{Binding Path=CurrentPage}" />


Everytime it loads page in it, increases memory size.

I would like to know, what's happening here. Why it increases memory size everytime I load a page in it.

Thanks in advance :)
Posted
Updated 28-Jun-11 22:16pm
v2
Comments
Sergey Alexandrovich Kryukov 29-Jun-11 4:09am    
OK, memory size, but what makes you feel a leak? Don't get me wrong, leaks are possible even on a managed platform. But how do you know?
--SA
Sanjay J Patolia 29-Jun-11 4:12am    
When I click on next button to load a next page in it. This causes memory size increase. everytime I click on next or previous button and every move will load a specific page in a HeaderedContentControl. I meant to say that if it has been loaded once and I click on next or previous it should just give a reference or some. but it increases memory size evrytime.
Sanjay J Patolia 29-Jun-11 4:14am    
Is above process an inbuild behaviour or what I am not getting it!!!
Mark Salsbery 29-Jun-11 17:19pm    
.NET will gleefully keep allocating memory if it's available until it decides to free some up. Like others have asked, how do you know it's a leak?

1 solution

Without seeing your code, it's difficult to say, but I have a suspicion that the problem is probably event handler leaks (they are the commonest cause of leaks in .NET). Make sure that you are deallocating any event handlers that you have allocated before you leave the page.
 
Share this answer
 
Comments
Sanjay J Patolia 29-Jun-11 4:27am    
Well I have verified with event handlers it does not create the leak here. May be something else.
Pete O'Hanlon 29-Jun-11 4:49am    
Again, without seeing your code it's hard to verify. Sorry about that.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900