1

I am designing an app that has a ListPicker with over 90 items. Each item consists of 2 PNG images(< 3KB in size each) and some text.

I have created a new class to represent my item and I am creating a list of this class using

List<ClassName> ClassNameList = new List<ClassName>();

in code and appending items to the list using:

ClassNameList.Add(new ClassName() {var1=..., var2=...});

In my case, var1 and var2 are paths to PNG images that are included in project.

Then, I am using databinding in <itemtemplate> to bind my items to list.

When I load the ListPicker in emulator, memory usage shoots up above 256MB. So, I can't submit my app for newer, 256MB RAM phones. Is there any way to reduce the memory usage?

tumchaaditya
  • 1,267
  • 7
  • 19
  • 49
  • Try to store all the images in isolated storage and load the items from the storage when user enters the view and delete the older items – SENTHIL KUMAR May 02 '12 at 06:53
  • can you please elaborate a little more? especially the part where you say i should "delete older items". – tumchaaditya May 02 '12 at 09:03
  • You are adding images to the listpicker. for example If u scroll to the alphabet H, then load the items for H and G,I remove all the other alphabets item many examples are there its similar to lazy loading in listbox but here you are removing the items in the top when user reaches the specific point. – SENTHIL KUMAR May 02 '12 at 09:12
  • ok. i'll search a bit on this. btw, I am not using longlistpicker. Mine doesn't show that fancy grid of letters – tumchaaditya May 02 '12 at 09:16
  • Oh then it will become very easy man try it – SENTHIL KUMAR May 02 '12 at 09:23

1 Answers1

1

The image file size doesn't mean that it will use the same amount of memory; often images are in a compressed format (in your case PNG is), having a reduced file size. This however doesn't mean it will be using less memory. Also read this topic (although it is about WPF, it is still the same principle for any situation).

I don't know your case, but if you have many same pictures, you might want to think about caching your images (or using for example the proxy pattern) to reduce duplicate images in memory.

Styxxy
  • 7,462
  • 3
  • 40
  • 45
  • i read the topic. but the images that i am trying to load are already less than 60x60 px. So, I don't see any point in further using DecodedPixelWidth – tumchaaditya May 02 '12 at 09:04
  • You can also try following tips and tricks on MSDN: http://msdn.microsoft.com/en-us/library/cc716879.aspx And further, maybe you should look at lazy loading, so you don't load all images already (and you can "dispose" images that are not near the displayed items as well). – Styxxy May 02 '12 at 09:41