English 中文(简体)
• 如何在银灯/WPF上解放援助团?
原标题:How to Free RAM at Silverlight/WPF?

How to Free RAM at Silverlight/WPF ? I define a UserControl MyUC that has a Image and three Textblock. I add 10000 MyUCs to a Grid, then clear the Grid s Children,but RAM is not Freed! Why? MyUC:

<Grid x:Name="LayoutRoot" Background="White">
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="32"/>
        <ColumnDefinition Width="Auto"/>
    </Grid.ColumnDefinitions>
    <Image Grid.Column="0" Source="{Binding ICO}" Width="32" Height="32"/>
    <StackPanel Grid.Column="1" Orientation="Vertical" Width="359" Margin="0,0,-189,0">
        <TextBlock Text="{Binding ID}"/>
        <TextBlock Text="{Binding Name}"/>
        <TextBlock Text="{Binding URL}"/>
    </StackPanel>
</Grid>

法典:

MyUC uc = null;
for (int i = 0; i < 10000; i++)
{
  uc = new MyUC();
  this.LayoutRoot.Children.Clear();
  this.LayoutRoot.Children.Add(uc);
}

帮助我? 3KS!

最佳回答

很短的答复是,如果你提供的话,你没有明确表示要释放记忆。

由于贵重物品类别的每一例都不属于范围,因此,垃圾收集器将确定不再能够使用。 在下一次停车场收集时,将标出无法兑现的事例,记忆将紧凑。 它对如何做到这一点至关重要。 NET在发挥作用。

您的测验记忆的诊断是否正在发现垃圾收集的影响是另一个例子,你没有提供关于你使用的诊断信息。

Garbage collection in the Microsoft .NET common language runtime environment completely absolves the developer from tracking memory usage and knowing when to free memory. However, you ll want to understand how it works. Part 1 of this two-part article on .NET garbage collection

资料来源:Jefferyrichter 。 垃圾收集:Microsoft .NET Framework 的自动记忆管理

问题回答

暂无回答




相关问题
Silverlight Rich text box control

Our team decided that we need our own custom Rich text box control for Silverlight app we are developing. We looked at existing controls mentioned at A good rich text control for Silverlight but ...

Silverlight ImageBrush not rendering (with Bing Map Control)

I m trying to add an image to a Pushpin instance from the Silverlight Bing Map Control, but I can t seem to get it to render (the pushpin renders fine). This is probably a general WPF question rather ...

Silverlight OpenFileDialog DoEvents equivalent

I m processing large files after they are selected by the user. My code looks like the following: if (FileDialog.ShowDialog() == true) { // process really big file } This freezes up the UI so ...

list of controls with templates in silverlight

Does anyone know where to find a list of controls that you can set the template on in Silverlight? I ve wasted several hours now trying to create control templates only to find that the control doesn ...

Silverlight, Updating the UI during processing

I have a simple silverlight multifile upload application, and i want to provide the user with some feedback, right now its only in a test phase and i dont have the webservice. Somehow i cant get the ...

Silverlight 3 - FindName returns null

This looks a bug to me.. Using Silverlight 3 and i have a user control defined in XAML and trying to access the object during runtime returns a null. <Grid> <common:CommonGridEditPanel x:...

silverlight 3 collection binding

Someone please help me understand why this binding does not work... I have a class called SelectionManager with a property called dates which is populated by a WCF service. The property is an ...

热门标签