Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

[Bug] [MauiCompat] ByteArrayToImageSourceConverter Memory runaway #1980

Open
Skyhikeeper opened this issue Aug 16, 2023 · 0 comments
Open

[Bug] [MauiCompat] ByteArrayToImageSourceConverter Memory runaway #1980

Skyhikeeper opened this issue Aug 16, 2023 · 0 comments
Labels
bug Something isn't working. Breaky break. maui-compat

Comments

@Skyhikeeper
Copy link

Description

When using the toolkit to display an image on a view the resource is never discarded so the amount of memory usage grows all the time.

Stack Trace

CommunityToolkit.Maui.Converters.ByteArrayToImageSourceConverter+<>c__DisplayClass8_0 38635 6358971072 6358971072

Link to Reproduction Sample

Steps to Reproduce

  1. add the toolkit to the xaml view

<ContentPage.Resources>
    <ResourceDictionary>
        <toolkit:ByteArrayToImageSourceConverter x:Key="ByteArrayToImageSourceConverter" />
    </ResourceDictionary>
</ContentPage.Resources>

<Grid RowDefinitions = "0.75*,150,0.1*" 
      ColumnDefinitions =" *,*,*,*,*"
      Margin="5,0,5,0">
    <Image Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="5" 
        MinimumHeightRequest="50" 
        Margin="5"
        Source="{Binding BigPic,Mode=OneWay, Converter={StaticResource ByteArrayToImageSourceConverter}}" 
        Aspect="AspectFit">
    </Image>
    <Image Grid.Row="1" Grid.Column="0" 
           Margin="5,0,5,0" 
           MaximumHeightRequest="150" 
           Aspect="AspectFit" 
           Source="{Binding Pic1,Mode=OneWay, Converter={StaticResource ByteArrayToImageSourceConverter}}" 
           HorizontalOptions="Center" >
    </Image>
    <Image Grid.Row="1" Grid.Column="1" 
           Margin="5,0,5,0" 
           MaximumHeightRequest="150" 
           Aspect="AspectFit" 
           Source="{Binding Pic2,Mode=OneWay, Converter={StaticResource ByteArrayToImageSourceConverter}}" 
           HorizontalOptions="Center">
    </Image>
    <Image Grid.Row="1" Grid.Column="2" 
           Margin="5,0,5,0" 
           MaximumHeightRequest="150" 
           Aspect="AspectFit" 
           Source="{Binding Pic3,Mode=OneWay, Converter={StaticResource ByteArrayToImageSourceConverter}}" 
           HorizontalOptions="Center">
    </Image>
    <Image Grid.Row="1" Grid.Column="3" 
           Margin="5,0,5,0" 
           MaximumHeightRequest="150" 
           Aspect="AspectFit" 
           Source="{Binding Pic4,Mode=OneWay, Converter={StaticResource ByteArrayToImageSourceConverter}}"  
           HorizontalOptions="Center">
    </Image>
    <Image Grid.Row="1" Grid.Column="4" 
           Margin="5,0,5,0" 
           MaximumHeightRequest="150" 
           Aspect="AspectFit" 
           Source="{Binding Pic5,Mode=OneWay, Converter={StaticResource ByteArrayToImageSourceConverter}}" 
           HorizontalOptions="Center">
    </Image>
    <HorizontalStackLayout Grid.Row="3" Grid.ColumnSpan="5" HorizontalOptions="Center" >
        <Button
            Margin="0,0,50,0"
        Text="Reconnect"
        SemanticProperties.Hint="Reconnect to the control room"
        Command="{Binding ReconnectClickedCommand}"
        MaximumHeightRequest="50"/>
        <Button
        Text="{Binding ModelPauseStatus}"
        SemanticProperties.Hint="Pause the Image roataion"
        Command="{Binding PauseClickedCommand}"
        MaximumHeightRequest="50"/>
    </HorizontalStackLayout>
</Grid>
  1. process images to display on the view using the MVVM toolkit

  2. run application and the memory usage just increase

Expected Behavior

after each display of the image, I expect the memory usage to reduce.

Actual Behavior

after each display of the image, the memory continues to increase.

Basic Information

  • Version with issue:
  • Last known good version: Unknown
  • IDE: Visual Studio 2022 version 17.7.1
  • Platform Target Frameworks: .net7
    • iOS: na
    • Android: na
    • Windows: Windows 11
  • Android Support Library Version:
  • Nuget Packages: CommunityToolkit.Maui
  • Affected Devices: all
  • MAUI Version:

Workaround

none found

Reproduction imagery

Screenshot 2023-08-16 070208

@Skyhikeeper Skyhikeeper added bug Something isn't working. Breaky break. maui-compat labels Aug 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working. Breaky break. maui-compat
Projects
None yet
Development

No branches or pull requests

1 participant