Reputation: 11
Below is the error :
05-01 01:36:39.414 I/art ( 4758): Waiting for a blocking GC Alloc
05-01 01:36:39.430 I/art ( 4758): WaitForGcToComplete blocked for 15.801ms for cause Alloc
05-01 01:36:39.430 I/art ( 4758): Starting a blocking GC Alloc
05-01 01:36:39.459 I/art ( 4758): Waiting for a blocking GC Alloc
05-01 01:36:39.477 I/art ( 4758): Clamp target GC heap from 111MB to 96MB
05-01 01:36:39.477 I/art ( 4758): WaitForGcToComplete blocked for 17.695ms for cause Alloc
05-01 01:36:39.477 I/art ( 4758): Starting a blocking GC Alloc
05-01 01:36:39.483 I/art ( 4758): Waiting for a blocking GC Alloc
05-01 01:36:39.487 I/art ( 4758): Starting a blocking GC Alloc
05-01 01:36:39.487 I/art ( 4758): Starting a blocking GC Alloc
05-01 01:36:39.503 I/art ( 4758): Clamp target GC heap from 111MB to 96MB
05-01 01:36:39.503 I/art ( 4758): Alloc partial concurrent mark sweep GC freed 192(7KB) AllocSpace objects, 0(0B) LOS objects, 0% free, 95MB/96MB, paused 719us total 15.608ms
05-01 01:36:39.503 I/art ( 4758): Starting a blocking GC Alloc
05-01 01:36:39.507 I/art ( 4758): Starting a blocking GC Alloc
05-01 01:36:39.522 I/art ( 4758): Clamp target GC heap from 111MB to 96MB
05-01 01:36:39.522 I/art ( 4758): Alloc concurrent mark sweep GC freed 8(256B) AllocSpace objects, 0(0B) LOS objects, 0% free, 95MB/96MB, paused 599us total 15.143ms
05-01 01:36:39.522 I/art ( 4758): Forcing collection of SoftReferences for 42KB allocation
05-01 01:36:39.522 I/art ( 4758): Starting a blocking GC Alloc
05-01 01:36:39.538 I/art ( 4758): Clamp target GC heap from 111MB to 96MB
05-01 01:36:39.539 I/art ( 4758): Alloc concurrent mark sweep GC freed 3(96B) AllocSpace objects, 0(0B) LOS objects, 0% free, 95MB/96MB, paused 467us total 16.050ms
05-01 01:36:39.539 W/art ( 4758): Throwing OutOfMemoryError "Failed to allocate a 43612 byte allocation with 20680 free bytes and 20KB until OOM"
05-01 01:36:39.539 I/art ( 4758): Starting a blocking GC Alloc
05-01 01:36:39.539 I/art ( 4758): Starting a blocking GC Alloc
05-01 01:36:39.542 I/art ( 4758): Starting a blocking GC Alloc
05-01 01:36:39.557 I/art ( 4758): Clamp target GC heap from 111MB to 96MB
05-01 01:36:39.557 I/art ( 4758): Alloc partial concurrent mark sweep GC freed 6(192B) AllocSpace objects, 0(0B) LOS objects, 0% free, 95MB/96MB, paused 494us total 14.784ms
05-01 01:36:39.557 I/art ( 4758): Starting a blocking GC Alloc
05-01 01:36:39.571 I/art ( 4758): Clamp target GC heap from 111MB to 96MB
05-01 01:36:39.571 I/art ( 4758): Alloc concurrent mark sweep GC freed 1(32B) AllocSpace objects, 0(0B) LOS objects, 0% free, 95MB/96MB, paused 430us total 14.253ms
05-01 01:36:39.571 I/art ( 4758): Forcing collection of SoftReferences for 42KB allocation
05-01 01:36:39.571 I/art ( 4758): Starting a blocking GC Alloc
05-01 01:36:39.588 I/art ( 4758): Clamp target GC heap from 111MB to 96MB
05-01 01:36:39.588 I/art ( 4758): Alloc concurrent mark sweep GC freed 2(64B) AllocSpace objects, 0(0B) LOS objects, 0% free, 95MB/96MB, paused 489us total 16.563ms
05-01 01:36:39.588 W/art ( 4758): Throwing OutOfMemoryError "Failed to allocate a 43612 byte allocation with 20680 free bytes and 20KB until OOM"
05-01 01:36:39.589 I/art ( 4758): WaitForGcToComplete blocked for 65.985ms for cause Background
I have tried setting the largeHeap as true in android manifest file. Also, I thought that this might be because of the images in my page, but I am getting this error even after removing all images from m page.
I have also set the java max heap size in options to 2G but problem still persists.
Here's the code
public partial class SingleRetailerBooking : ContentPage
{
int expanded = 0;
bool headertapped = false;
string colorValueWhenSetTapped;
AllProducts products;
public List<String> colorList, offerMonthsListAll;
private Dictionary<String, List<String>> colorsWithSizes = new Dictionary<String, List<String>>();
public List<String> colorWithSizeList;
private Dictionary<String, Dictionary<String, int>> sizeWiseOrders = new Dictionary<string, Dictionary<string, int>>(); //contains all sizes values respective to the colors
private ObservableCollection<ExpandableHeaderClass> _allGroups;
private ObservableCollection<ExpandableHeaderClass> _expandableGroup;
public ObservableCollection<SingleBookingDataModel> singlebookingdata { get; set; }
string s,val;
int selectedIndex;
ItemCell cell = new ItemCell();
private Button set_id;
private Dictionary<String, int> totalQuantity;
private Dictionary<string, Dictionary<String,int>> setForColors = new Dictionary<string, Dictionary<String,int>>();
Dictionary<String, int> OfferMonthWiseSets = new Dictionary<string, int>();
Dictionary<String, String> optionsList = new Dictionary<String, String>();
List<String> offerMonthList = new List<string>();
ExpandableHeaderClass exp;
String clicked_set_or_item_button = "";
public SingleRetailerBooking(AllProducts product, List<String> colorList, Dictionary<String, String> optionsList, List<String> offerMonthList)
{
this.products = product;
this.colorList = colorList;
this.optionsList = optionsList;
this.offerMonthList = offerMonthList;
ProductsDataAccess pda = new ProductsDataAccess();
pda.AddProductsToCart();
Application.Current.Properties["ColorList"] = colorList;
if (Application.Current.Properties.ContainsKey("SizeListColorwise"))
{
colorsWithSizes = Application.Current.Properties["SizeListColorwise"] as Dictionary<String, List<String>>;
}
string offerMon = product.OfferMonths;
offerMonthList = offerMon.Split(',').ToList();
for (int i = 0; i < colorList.Count; i++)
{
if (colorsWithSizes.ContainsKey(colorList[i]))
{
Dictionary<String, int> ordersDictionary = new Dictionary<String, int>();
List<String> sizes = colorsWithSizes.ElementAt(i).Value;
for (int z = 0; z < sizes.Count; z++)
{
ordersDictionary.Add(sizes[z], 1);
}
sizeWiseOrders.Add(colorList[i], ordersDictionary);
}
Dictionary<string, int> dict = new Dictionary<string, int>();
for (int a=0;a<offerMonthList.Count;a++)
{
dict.Add(offerMonthList[a],0);
}
setForColors.Add(colorList[i], dict);
}
Application.Current.Properties["sizeWiseOrders"] = sizeWiseOrders;
Application.Current.Properties["setForColors"] = setForColors;
NavigationPage.SetHasNavigationBar(this, false);
InitializeComponent();
//lstView.ItemsSource = GetItems();
//exp = new ExpandableHeaderClass();
//_allGroups = exp.ExpandableHeaderClassReturn();
//UpdateListContent();
// An Example DataSource
//MyDataSource = new List<CarouselData>() { new CarouselData() { Name = "Screen.png" },
// new CarouselData() { Name = "fieldassistlogo.png" },
// new CarouselData() { Name = "icon.png" },
// new CarouselData() { Name = "password.png" }};
BindingContext = this;
TapGestureRecognizer tap = new TapGestureRecognizer();
tap.Tapped += (object sender, EventArgs e) =>
{
Page page = new NavigationPage(new BookingStatus());
Navigation.PushAsync(page);
NavigationPage.SetHasNavigationBar(page, false);
};
cartImage.GestureRecognizers.Add(tap);
TapGestureRecognizer menuIconTapped = new TapGestureRecognizer();
menuIconTapped.Tapped += (object sender, EventArgs e) =>
{
MessagingCenter.Send(this, "OpenMaster");
};
menuImage.GestureRecognizers.Add(menuIconTapped);
TapGestureRecognizer reviewIconTapped = new TapGestureRecognizer();
reviewIconTapped.Tapped += (object sender, EventArgs e) =>
{
reviewgrid.IsVisible = true;
};
reviewImage.GestureRecognizers.Add(reviewIconTapped);
lstView.ItemSelected += (sender, e) => lstView.SelectedItem = null;
//SetAllProductData(products);
}
private async Task getTotalQuantity(Dictionary<string, Dictionary<string, int>> setForColors, Dictionary<String, Dictionary<String, int>> sizeWiseOrders)
{
int setCount = 0;
totalQuantity = new Dictionary<string, int>();
foreach (var item in sizeWiseOrders)
{
foreach (var subitem in setForColors)
{
if (item.Key == subitem.Key)
{
foreach (var set in subitem.Value)
{
int totalCount = 0;
setCount = set.Value;
Dictionary<String, int> dictNew = item.Value;
List<int> newList = dictNew.Values.ToList();
for (int z = 0; z < newList.Count; z++)
{
totalCount += setCount * newList[z];
}
totalQuantity.Add(item.Key, totalCount);
}
}
}
}
Application.Current.Properties["totalQuantity"] = totalQuantity;
}
//public List<CarouselData> MyDataSource { get; set; } // Must have default value or be set before the BindingContext is set.
//private int _position;
//public int Position { get { return _position; } set { _position = value; OnPropertyChanged(); } }
private void close(object sender, EventArgs e)
{
numbergrid.IsVisible = false;
cancelandsavegrid.IsVisible = true;
for(int i = 0; i < _allGroups.Count; i++)
{
_allGroups[i].Expanded = false;
}
UpdateListContent();
}
private async Task Number_Button_Clicked(object sender, EventArgs e)
{
Button id = null;
String labelText = "";
if (Application.Current.Properties.ContainsKey("ExpandableItemCellButtonId"))
{
if (!Application.Current.Properties["ExpandableItemCellButtonId"].ToString().Equals(""))
{
id = Application.Current.Properties["ExpandableItemCellButtonId"] as Button;
labelText = Application.Current.Properties["ExpandableItemCellLabelText"] as String;
clicked_set_or_item_button = "itemButtonClicked";
}
}
Button d = (Button)sender;
s = d.Text;
if (id != null && clicked_set_or_item_button.Equals("itemButtonClicked"))
{
id.Text = s;
if (sizeWiseOrders.ContainsKey(val))
{
Dictionary<String, int> dict = sizeWiseOrders[val];
if (dict.ContainsKey(labelText))
{
dict[labelText] = Int32.Parse(s);
}
}
}
if (set_id != null && clicked_set_or_item_button.Equals("setClicked"))
{
set_id.Text = s;
var colorValue = set_id.CommandParameter.ToString();
if (offerMonthList.Count==1)
{
setForColors[colorValue][offerMonthList[0]] = Int32.Parse(s);
}
else
{
}
}
await getTotalQuantity(setForColors, sizeWiseOrders);
List<int> values = new List<int>();
foreach (var item in totalQuantity)
{
values.Add(item.Value);
}
for (int i=0; i< _allGroups.Count; i++)
{
if (values.Count > 0)
_allGroups[i].Quantity = values[i];
else
_allGroups[i].Quantity = 0;
}
UpdateListContent();
}
//private void saveOrder(object sender, EventArgs e)
//{
// ProductsDataAccess pda = new ProductsDataAccess();
// pda.AddProductsToCart();
//}
public void HeaderTapped(Object sender, EventArgs args)
{
Button btn = (Button)sender;
val = btn.CommandParameter.ToString();
Application.Current.Properties["selectedIndexColor"] = val;
for (int i=0;i<colorList.Count;i++)
{
if (colorList[i]==val)
{
selectedIndex = i;
Application.Current.Properties["selectedIndex"] = selectedIndex;
}
}
_allGroups[selectedIndex].Expanded = !_allGroups[selectedIndex].Expanded;
expanded = selectedIndex;
UpdateListContent();
if (headertapped)
{
cancelandsavegrid.IsVisible = false;
numbergrid.IsVisible = true;
headertapped = false;
}
else{
cancelandsavegrid.IsVisible = true;
numbergrid.IsVisible = false;
headertapped = true;
}
}
public void SetTapped(Object sender, EventArgs args)
{
Application.Current.Properties["ExpandableItemCellButtonId"] = "";
clicked_set_or_item_button = "setClicked";
set_id = (Button)sender;
colorValueWhenSetTapped = set_id.CommandParameter.ToString();
numbergrid.IsVisible = true;
cancelandsavegrid.IsVisible = false;
}
private void Review_Cancel_Button_Clicked(object sender, EventArgs e)
{
reviewgrid.IsVisible = false;
}
private void UpdateListContent()
{
int count = 0;
_expandableGroup = new ObservableCollection<ExpandableHeaderClass>();
foreach (ExpandableHeaderClass group in _allGroups)
{
ExpandableHeaderClass newgroup = new ExpandableHeaderClass(group.Name, group.Set, group.Quantity, group.Expanded);
if (group.Expanded)
{
headertapped = true;
count = count + 1;
foreach (Child child in group)
{
newgroup.Add(child);
}
}
_expandableGroup.Add(newgroup);
}
lstView.HeightRequest = colorList.Count * 60 + count * 100;
lstView.ItemsSource = _expandableGroup;
}
private async Task SetAllProductData(AllProducts product)
{
ProductName.Text = products.Name;
Description.Text = products.Description;
BrandName.Text = product.Brand;
StypeName.Text = product.SubCategory;
//OfferMonthName.Text = product.OfferMonths;
CategoryName.Text = product.Category;
GenderName.Text = product.Gender;
MRPValue.Text = product.MRP;
CollectionName.Text = product.Collection;
FitName.Text = product.Fit;
FabricName.Text = product.Fabric;
FinishName.Text = product.Finish;
MoodName.Text = product.Mood;
OfferMonthName.Text = String.Join(",", offerMonthList);
bool promoted = product.Promoted;
if (promoted)
Recommended.IsVisible = true;
else
Recommended.IsVisible = false;
Productdata productData = new Productdata(product, productGrid);
await getTotalQuantity(setForColors, sizeWiseOrders);
}
public async void SaveOrder(Object sender, EventArgs args)
{
int setcount = 0;
//for (int i=0;i<setForColors.Count;i++)
//{
// setcount += setForColors[i];
//}
foreach (var newitem in setForColors)
{
foreach (var subitem in newitem.Value)
{
setcount += subitem.Value;
}
}
if (setcount==0)
{
//await DisplayAlert("","Please enter atleat one set","OK");
await Navigation.PopAsync();
var existingPages = Navigation.NavigationStack.ToList();
Page Qrpage = new NavigationPage(new QRScanningPage());
await Navigation.PushAsync(Qrpage);
NavigationPage.SetHasNavigationBar(Qrpage, false);
}
else
{
Dictionary<String, int> dict1;
Dictionary<String, Dictionary<String, int>> dict2 = new Dictionary<string, Dictionary<String, int>>();
foreach (var setColors in setForColors)
{
foreach (var sizeOrders in sizeWiseOrders)
{
if (sizeOrders.Key == setColors.Key)
{
dict1 = new Dictionary<string, int>();
foreach (var item1 in setColors.Value)
{
int count = 0;
foreach (var item2 in sizeOrders.Value)
{
count += item1.Value * item2.Value;
}
dict1.Add(item1.Key, count);
}
dict2.Add(sizeOrders.Key, dict1);
}
}
}
foreach (var item in optionsList)
{
foreach (var subItem in sizeWiseOrders)
{
if (item.Key == subItem.Key)
{
Dictionary<String, int> dict = sizeWiseOrders[item.Key];
Dictionary<String, int> quantityWithSets = dict2[item.Key];
Dictionary<String, int> sets = setForColors[item.Key];
string result = string.Join(";", dict.Select(m => m.Key + ":" + m.Value).ToArray());
String setResult = string.Join(";", sets.Select(m => m.Key + ":" + m.Value).ToArray());
String quantityString = string.Join(";", quantityWithSets.Select(m => m.Key + ":" + m.Value).ToArray());
var orderDetails = new RetailerBookingModel()
{
Option = item.Value,
Name = products.Name,
Price = Int32.Parse(products.MRP),
Description = products.Description,
Brand = products.Brand,
Category = products.Category,
ColorList = item.Key,
SizeWiseRatios = result,
Sets = setResult,
QuantityWithSets = quantityString,
Quantity = totalQuantity[item.Key],
Fit = products.Fit,
Collection = products.Collection
};
App.DAUtil.SaveSingleRetailerBooking(orderDetails);
}
}
}
await Navigation.PopAsync();
Page Qrpage = new NavigationPage(new QRScanningPage());
await Navigation.PushAsync(Qrpage);
NavigationPage.SetHasNavigationBar(Qrpage, false);
}
}
}
Upvotes: 0
Views: 330