> - Are these fields static or are they instance-fields?
     Yes, they're static.

> - When do you call loadAlphaBlinkingBitmaps or loadProxyBitmaps
     All the load Bitmaps methods are called in the gamescreen
constructor.

> - When do you clear out the mBitmap and mProxy caches? (in onPause,
> onDestroy, ...?)
     I clear my bitmaps in the gamescreen onDetachedFormWindow



On Mar 3, 8:26 pm, Streets Of Boston <flyingdutc...@gmail.com> wrote:
> The fields mProxy and mBitmap are a bit suspect here. You cache
> bitmaps in them.
>
> - Are these fields static or are they instance-fields?
> - When do you call loadAlphaBlinkingBitmaps or loadProxyBitmaps
> (during onCreate, during onPause, ...)
> - When do you clear out the mBitmap and mProxy caches? (in onPause,
> onDestroy, ...?)
>
> On Mar 3, 6:05 am, REvolver <luca.lupol...@gmail.com> wrote:
>
> > Ok,
>
> > Actually I load several Bitmaps using Bitmap.createBitmap(..) or
> > BitmapFactory.decodeResource(...).
> > In this snippet I use the first way
>
> >         static public void  loadProxyBitmpas(){
> >                 //load the sprites
> >                 BitmapFactory.Options op= new BitmapFactory.Options();
> >                 op.inPreferredConfig=Config.RGB_565;
> >                 int diceSize;
> >                 switch(Main.device){
> >                 case FWVGA:{
> >                         op.inScaled=false;
> >                         break;
> >                 }
> >                 case WVGA:{
> >                         op.inScaled=false;
> >                         break;
> >                 }
> >                 case QVGA:{
> > //                      diceSize=29;
> >                         break;
> >                 }
> >                 case HVGA:{
> >                         break;
> >                 }
> >                 }
> > //              if(Main.runningOnX10){
> > //                      op.inScaled=false;
> > //              }
> >                 int rsId=0;
> >                 Bitmap diceSide=null;
> >                 for (int j = 0; j < 3; j++) {
> >                         switch(j){
> >                                 case 0:{
> >                                         rsId=R.drawable.dice_white;
> >                                         break;
> >                                 }
> >                                 case 1:{
> >                                         rsId=R.drawable.dice_red;
> >                                         break;
> >                                 }
> >                                 case 2:{
> >                                         rsId=R.drawable.dice_black;
> >                                         break;
> >                                 }
> >                         }
> >                         Bitmap
> > tempBitmap=BitmapFactory.decodeResource(Main.instance.getResources(),rsId,o­p);
> >                         
> > diceSize=tempBitmap.getWidth()/NUMBER_OF_DICE_SPRITES;
> >                         Log.d("diceSize", " " + diceSize);
> >                         for (int i = 0; i < DiceBody.SPRITE_COUNT; i++) {
> >                                 Matrix matrix=null;
> >                                 if(Main.device==Device.QVGA){
> >                                         matrix=new Matrix();
> >                                         matrix.setScale(0.9f,0.9f);
> >                                 }
> >                                 diceSide = Bitmap.createBitmap(tempBitmap, 
> > i * diceSize, 0,
> > diceSize, diceSize,matrix,false);
>
> >                                 mProxy[i+(DiceBody.SPRITE_COUNT*j)] = 
> > diceSide;
> >                         }
> >                         tempBitmap.recycle();
> >                         tempBitmap=null;
>
> >                 }
> >     }
>
> > In the next snippet I use the BitmapFactory:
>
> >         static public void loadAlphaBlinkingBitmaps() {
> >                 BitmapFactory.Options op = new BitmapFactory.Options();
> >                 op.inPreferredConfig = Config.ARGB_4444;
> >                 switch(Main.device){
> >                 case FWVGA:{
> >                         op.inScaled=false;
> >                         break;
> >                 }
> >                 case WVGA:{
> >                         op.inScaled=false;
> >                         break;
> >                 }
> >                 case QVGA:{
> >                         break;
> >                 }
> >                 case HVGA:{
> >                         break;
> >                 }
> >                 }
> > //              if(Main.runningOnX10){
> > //                      op.inScaled=false;
> > //              }
> >                 mBitmap[0] =
> > BitmapFactory.decodeResource(Main.instance.getResources(),
> > R.drawable.nomove, op);
> >                 mBitmap[1] =
> > BitmapFactory.decodeResource(Main.instance.getResources(),
> > R.drawable.icon_fight_small,op);
> >                 mAnimation=new AlphaAnimation(0, 1);
> >                 mAnimation.setInterpolator(new SinInterpolator());
> >                 mAnimation.setDuration(1000);
> >                 mAnimation.setRepeatCount(Animation.INFINITE);
> >                 mAnimation.setRepeatMode(Animation.REVERSE);
>
> >         }
>
> > Obviusly there are much more Bitmaps loaded but always in the same
> > way.
>
> > Quite often the application crashes inflating the new screen layout
> > (of course it contains some imageview->bitmaps).
> > This is the GameScreen constructor:
>
> >         public GameScreen(Context context, AttributeSet attrs) {
> >                 super(context, attrs);
> >                 LayoutInflater inflater = Main.instance.getLayoutInflater();
> >                 toastView = inflater.inflate(R.layout.toast_level_name,
> >                 (ViewGroup) findViewById(R.id.toast_layout_root));
>
> >                 toast = new Toast(Main.instance);
> >                 toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
> >                 toast.setView(toastView);
> >                 toast.setDuration(Toast.LENGTH_SHORT);
>
> > //              Log.d("tag", "constructor gamescreen 2");
> >         }
>
> > All the bitmaps are loaded during the gamescreen inflation when the
> > surfaceview is created (Playfield constructor).
>
> > My main concern is:
> > Why if I'switch between this two views (Gamescreen and Gallery) 30
> > times, I have always the same amount of bitmap memory, and if I do it
> > 2 times after pause->resume->pause->resume my memory consumption grows
> > (driving me to a crash)?
>
> > On Feb 25, 6:03 pm, Streets Of Boston <flyingdutc...@gmail.com> wrote:
>
> > > It could be anything. You have to post some code-samples that you
> > > think code be suspicious.
> > > Check your (static) caches, if you have them.
>
> > > On Feb 25, 6:49 am, REvolver <luca.lupol...@gmail.com> wrote:
>
> > > > None?- Hide quoted text -
>
> > - Show quoted text -

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to