Expection Java.Lang.OutOfMemoryError also with 1G

Stefano M 91 Reputation points
2021-03-24T17:49:09.79+00:00

When I try to display a CarouselView with about 2-3 items I get the following exception:

> **Java.Lang.OutOfMemoryError:** ''

Log:

> 03-24 16:00:33.505 E/Bitmap  ( 9249): OOM allocating Bitmap with

> dimensions 630 x 16777078

I increased the Java memory to 1G in the AndroidManifest but the problem remains

     <Frame x:Name="ViewMesi" IsVisible="False" Grid.RowSpan="2" VerticalOptions="Center" HorizontalOptions="Center" Margin="40,30,40,0" HeightRequest="380" WidthRequest="300" BackgroundColor="{x:DynamicResource BgColor}" CornerRadius="15">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="45"/>
                        <RowDefinition Height="25"/>
                        <RowDefinition Height="210"/>
                        <RowDefinition Height="25"/>
                        <RowDefinition Height="45"/>
                    </Grid.RowDefinitions>

                    <Label Grid.Row="0" Margin="10,10,0,0" Text="Seleziona mese"  HorizontalTextAlignment="Center" TextColor="Gray" FontSize="22"/>

                    <controls:TintedImage x:Name="ArrowMesiIndietro" Grid.Row="1" Source="ArrowSmall" HorizontalOptions="Center" TintColor="Gray" Rotation="270"/>
                    <Button x:Name="MesiIndietro" Grid.Row="1" BackgroundColor="Transparent" Clicked="MeseIndietro_Clicked" IsVisible="false"/>

                    <CarouselView
                        x:Name="CVMesi"
                        Grid.Row="2"
                        Margin="15"
                        HorizontalOptions="Center"
                        VerticalOptions="Center"
                        PeekAreaInsets="110"
                        Loop="False">
                        <CarouselView.ItemsLayout>
                            <LinearItemsLayout Orientation="Vertical" ItemSpacing="6" SnapPointsAlignment="Center" SnapPointsType="MandatorySingle"/>
                        </CarouselView.ItemsLayout>
                        <CarouselView.ItemTemplate>
                            <DataTemplate>
                                <Grid>
                                    <Label Text="{Binding Name}" TextColor="{x:DynamicResource TextColor}" FontSize="20" HorizontalTextAlignment="Center"/>
                                    <Button BackgroundColor="Transparent"/>
                                </Grid>
                            </DataTemplate>
                        </CarouselView.ItemTemplate>
                    </CarouselView>
                    <BoxView HeightRequest="1" WidthRequest="200" Grid.Row="2" Margin="15,30,15,0" BackgroundColor="LightGray" Opacity="0.8" VerticalOptions="Center"/>
                    <BoxView HeightRequest="1" WidthRequest="200" Grid.Row="2" Margin="15,0,15,51" BackgroundColor="LightGray" Opacity="0.8" VerticalOptions="Center"/>

                    <controls:TintedImage x:Name="ArrowMesiAvanti" Grid.Row="3" Source="ArrowSmall" HorizontalOptions="Center" TintColor="Black" Rotation="90"/>
                    <Button x:Name="MesiAvanti" Grid.Row="3" BackgroundColor="Transparent" Clicked="MeseAvanti_Clicked"/>

                    <StackLayout Grid.Row="4" HorizontalOptions="Center" Orientation="Horizontal" Margin="0,0,0,10">
                        <Button Text="Annulla" HeightRequest="30" BackgroundColor="Transparent" TextColor="{x:DynamicResource TextColor}" FontSize="14" Clicked="CancellaVistaMese_Clicked"/>
                        <Button Text="Ok" HeightRequest="30" BackgroundColor="Transparent" TextColor="{x:DynamicResource TextColor}" FontSize="14" Clicked="MeseSelezionato_Clicked"/>
                    </StackLayout>
                </Grid>
            </Frame>

If I make the Carouselview visible inside, I get the exception, otherwise no

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,295 questions
{count} votes