CARVIEW |
Select Language
HTTP/2 200
date: Sat, 26 Jul 2025 04:24:22 GMT
content-type: text/html; charset=utf-8
vary: X-PJAX, X-PJAX-Container, Turbo-Visit, Turbo-Frame, X-Requested-With,Accept-Encoding, Accept, X-Requested-With
x-repository-download: git clone https://github.com/dotnet/maui.git
etag: W/"757e8130ba9e608acaf05cc471235efe"
cache-control: max-age=0, private, must-revalidate
strict-transport-security: max-age=31536000; includeSubdomains; preload
x-frame-options: deny
x-content-type-options: nosniff
x-xss-protection: 0
referrer-policy: no-referrer-when-downgrade
content-security-policy: default-src 'none'; base-uri 'self'; child-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/; connect-src 'self' uploads.github.com www.githubstatus.com collector.github.com raw.githubusercontent.com api.github.com github-cloud.s3.amazonaws.com github-production-repository-file-5c1aeb.s3.amazonaws.com github-production-upload-manifest-file-7fdce7.s3.amazonaws.com github-production-user-asset-6210df.s3.amazonaws.com *.rel.tunnels.api.visualstudio.com wss://*.rel.tunnels.api.visualstudio.com objects-origin.githubusercontent.com copilot-proxy.githubusercontent.com proxy.individual.githubcopilot.com proxy.business.githubcopilot.com proxy.enterprise.githubcopilot.com *.actions.githubusercontent.com wss://*.actions.githubusercontent.com productionresultssa0.blob.core.windows.net/ productionresultssa1.blob.core.windows.net/ productionresultssa2.blob.core.windows.net/ productionresultssa3.blob.core.windows.net/ productionresultssa4.blob.core.windows.net/ productionresultssa5.blob.core.windows.net/ productionresultssa6.blob.core.windows.net/ productionresultssa7.blob.core.windows.net/ productionresultssa8.blob.core.windows.net/ productionresultssa9.blob.core.windows.net/ productionresultssa10.blob.core.windows.net/ productionresultssa11.blob.core.windows.net/ productionresultssa12.blob.core.windows.net/ productionresultssa13.blob.core.windows.net/ productionresultssa14.blob.core.windows.net/ productionresultssa15.blob.core.windows.net/ productionresultssa16.blob.core.windows.net/ productionresultssa17.blob.core.windows.net/ productionresultssa18.blob.core.windows.net/ productionresultssa19.blob.core.windows.net/ github-production-repository-image-32fea6.s3.amazonaws.com github-production-release-asset-2e65be.s3.amazonaws.com insights.github.com wss://alive.github.com api.githubcopilot.com api.individual.githubcopilot.com api.business.githubcopilot.com api.enterprise.githubcopilot.com; font-src github.githubassets.com; form-action 'self' github.com gist.github.com copilot-workspace.githubnext.com objects-origin.githubusercontent.com; frame-ancestors 'none'; frame-src viewscreen.githubusercontent.com notebooks.githubusercontent.com; img-src 'self' data: blob: github.githubassets.com media.githubusercontent.com camo.githubusercontent.com identicons.github.com avatars.githubusercontent.com private-avatars.githubusercontent.com github-cloud.s3.amazonaws.com objects.githubusercontent.com release-assets.githubusercontent.com secured-user-images.githubusercontent.com/ user-images.githubusercontent.com/ private-user-images.githubusercontent.com opengraph.githubassets.com copilotprodattachments.blob.core.windows.net/github-production-copilot-attachments/ github-production-user-asset-6210df.s3.amazonaws.com customer-stories-feed.github.com spotlights-feed.github.com objects-origin.githubusercontent.com *.githubusercontent.com; manifest-src 'self'; media-src github.com user-images.githubusercontent.com/ secured-user-images.githubusercontent.com/ private-user-images.githubusercontent.com github-production-user-asset-6210df.s3.amazonaws.com gist.github.com; script-src github.githubassets.com; style-src 'unsafe-inline' github.githubassets.com; upgrade-insecure-requests; worker-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/
server: github.com
content-encoding: gzip
accept-ranges: bytes
set-cookie: _gh_sess=6TgDRNNX5N1CiQyD%2FlPL4Pc0HAY4d9D3Vleo%2BVw4%2BZ2JMAIjs14UK6yc8R0Qy3i0pqmQCO22fGJQcgduSZeHPVQgaGgFJdt1RODv5yMuWl3VH1QWxQ8qiWW5HGY%2B1HZn6tqLNh2ZfqtNNYR8luQgWQ3sZaE7%2BQl8kC%2F9lZP7uy1Gpb%2FJ6iLN98OEUeuaLL9Ntxfb5PlaakZ109soI72Ez0V%2B%2Fl5yKLghTeZhu8lQ2R9564m8S3rKXHTK1zpgdLVgZXEx6UTq3xYMNuK%2BSJzp%2Fg%3D%3D--9ZpUF1HHwtGqiLRS--5sPg9BuS3JIf7FJMqTCTsA%3D%3D; Path=/; HttpOnly; Secure; SameSite=Lax
set-cookie: _octo=GH1.1.1440116565.1753503861; Path=/; Domain=github.com; Expires=Sun, 26 Jul 2026 04:24:21 GMT; Secure; SameSite=Lax
set-cookie: logged_in=no; Path=/; Domain=github.com; Expires=Sun, 26 Jul 2026 04:24:21 GMT; HttpOnly; Secure; SameSite=Lax
x-github-request-id: 9464:3240E6:157F76:204B30:68845875
[controls] fix memory leak with Grid Row/ColumnDefinitions (#16145) · dotnet/maui@443d3a0 · GitHub
Copy file name to clipboardExpand all lines: src/Controls/src/Core/DefinitionCollection.cs
Copy file name to clipboardExpand all lines: src/Controls/tests/Core.UnitTests/Layouts/GridLayoutTests.cs
Skip to content
Navigation Menu
{{ message }}
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit 443d3a0
authored
[controls] fix memory leak with Grid Row/ColumnDefinitions (#16145)
Context: #15860
In a customer's app, they have the setup:
<!-- Resources/Styles/Styles.xaml -->
<Style TargetType="Grid" x:Key="GridStyleWithColumnDefinitions">
<Setter Property="ColumnDefinitions" Value="18,*"/>
</Style>
Then a page with:
<Grid Style="{StaticResource GridStyleWithColumnDefinitions}" />
Navigating forward & back from this page would show that the entire
`Page` would live forever! What is interesting, is simply removing the
Grid's `Style` solved the problem?!?
I narrowed this down to a unit test:
[Fact]
public async Task ColumnDefinitionDoesNotLeak()
{
// Long-lived column, like from a Style in App.Resources
var column = new ColumnDefinition();
WeakReference reference;
{
var grid = new Grid();
grid.ColumnDefinitions.Add(column);
reference = new(grid);
}
await Task.Yield();
GC.Collect();
GC.WaitForPendingFinalizers();
Assert.False(reference.IsAlive, "Grid should not be alive!");
}
https://github.com/dotnet/maui/blob/cda3eb3381cfb686567ed05e3eb8e8f26c02d785/src/Controls/src/Core/Layout/Grid.cs#L20
`Grid` subscribes to `DefinitionCollection<T>.ItemSizeChanged`, and in
this case the `DefinitionCollection<T>` lived indefinitely in an
application-wide `ResourceDictionary`.
The simplest solution is to make the `ItemSizeChanged` event use
`WeakEventManager` as was done for other events like
`Application.RequestedThemeChanged`:
https://github.com/dotnet/maui/blob/cda3eb3381cfb686567ed05e3eb8e8f26c02d785/src/Controls/src/Core/Application/Application.cs#L221-L225
Since MAUI owns the property, we can use the simple solution here.
This is one issue solved in the customer app, but I will need to retest
the app in #15860 to see if there are further issues.1 parent 19c441d commit 443d3a0Copy full SHA for 443d3a0
File tree
Expand file treeCollapse file tree
2 files changed
+50
-5
lines changedFilter options
- src/Controls
- src/Core
- tests/Core.UnitTests/Layouts
Expand file treeCollapse file tree
2 files changed
+50
-5
lines changedsrc/Controls/src/Core/DefinitionCollection.cs
Copy file name to clipboardExpand all lines: src/Controls/src/Core/DefinitionCollection.cs+7-4Lines changed: 7 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
7 | 7 |
| |
8 | 8 |
| |
9 | 9 |
| |
| 10 | + | |
10 | 11 |
| |
11 | 12 |
| |
12 | 13 |
| |
| |||
101 | 102 |
| |
102 | 103 |
| |
103 | 104 |
| |
104 |
| - | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
105 | 110 |
| |
106 | 111 |
| |
107 | 112 |
| |
108 |
| - | |
109 |
| - | |
110 |
| - | |
| 113 | + | |
111 | 114 |
| |
112 | 115 |
| |
113 | 116 |
|
src/Controls/tests/Core.UnitTests/Layouts/GridLayoutTests.cs
Copy file name to clipboardExpand all lines: src/Controls/tests/Core.UnitTests/Layouts/GridLayoutTests.cs+43-1Lines changed: 43 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1 |
| - | |
| 1 | + | |
| 2 | + | |
| 3 | + | |
2 | 4 |
| |
3 | 5 |
| |
4 | 6 |
| |
| |||
184 | 186 |
| |
185 | 187 |
| |
186 | 188 |
| |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
187 | 229 |
| |
188 | 230 |
|
You can’t perform that action at this time.
0 commit comments