mohasad

hi ,
i have been in developing application in smartphone using c# .. i am using visual studio 2005 .... for my application i have loaded the resoueces using the following code ...
Stream s ;
Bitmap img_btYellow;
s = this.GetType().Assembly.GetManifestResourceStream("Widgets.res.avblue.png");
img_btYellow = new Bitmap(s);
s.Close();

i have loaded 8 '.png' images through the above code using the same stream ' s ' . the application is running fine in emulator .... but it is showing out of memory exception in the exe created inside the bin folder ... even i tried using singleton object for all the classes , that i have used .. but it s still showing the same exception .. could anyone help me in resolving this issue ..




Re: Smart Devices General regarding memory exception

Mohit Gogia

Moving to Smart Devices General forum where it has got better chances of being answered.

-Thanks,

Mohit





Re: Smart Devices General regarding memory exception

Ilya Tumanov

You have to dispose of all these bitmaps as soon as you done using the. Also keep in mind bitmaps are expanded into memory potentially taking huge amounts of RAM. Small 100K JPEG or PNG can be expanded to megabytes in RAM. Considering devices are limited to 32 MB (~25 available for application) of virtual RAM that would lead to OOM exception very quickly. Consider scaling these bitmaps down to, say. VGA resolution to save RAM.






Re: Smart Devices General regarding memory exception

mohasad

thanks Tumanov . actually i have been involved in game development . so i ll be using the bitmaps oftenly . if i dispose how can i use it back .moreover in my game , eventhough i have used a single refresh () throughout my application , while handling keyactions , the screen is flickering .i have to sort out this problem . if not i cannot proceed . i have searched throughout the web , but i cannot find the suitable solution.
thanks
sadiq





Re: Smart Devices General regarding memory exception

Ilya Tumanov

You should only dispose of something you no longer need. If you dispose of bitmap you would have to recreate it if it's needed again.

If it's a game tiny QVGA (or at best VGA) bitmaps should be used. Scale down all your bitmaps to that resolution to save memory and improve performance.

As to flickering, search for "double buffering", that¡¯s the technique you¡¯d need to use. It¡¯s been discussed quite a few times.






Re: Smart Devices General regarding memory exception

mohasad

hi ilya ,
so there is no other way than double buffering in order to control flickering. wheather the .NET compact frameWork is bilt upon double buffering . if so how to implement double buffering in our application





Re: Smart Devices General regarding memory exception

mohasad

hi Ilya,
i had even tried with Double buffering concept . still the screen is flickering in the emulator .
thanks
sadiq





Re: Smart Devices General regarding memory exception

Ilya Tumanov

There are many game samples available, go through them and see how they deal with this issue, then do the same.






Re: Smart Devices General regarding memory exception

mohasad

thanks Ilya. i had avoided flickering through overiding OnpaintBackground() method.

thanks sadiq