[android-developers] Re: instance count violation

2012-06-08 Thread marcin kolonko
thanks a lot for the answers. i also came up with the solution to ignore 
this error. :)

On Thursday, June 7, 2012 12:39:58 PM UTC+2, marcin kolonko wrote:

 hi,
 i have an app with two classes:

 *SelectItemActivity** extends **AbstractListActivity,* and *
 AbstractListActivity extends Activity*
 *
 *
 (~20 lines of code each) - not much to screw up i thought...

 links to pastebin:
 *AbstractListActivity* : http://pastebin.com/iKEa3d3a
 *SelectItemActivity : *http://pastebin.com/UC01gvTg
 *Menu*: http://pastebin.com/vjL1r28q

 now, when i click on the button in the actionbar, switch to landscape and 
 then back to portrait, the app crashes and i get this error:
 *android.os.StrictMode$InstanceCountViolation: class 
 ch.futurecom.MeetingMaid.view.SelectItemActivity; instances=2; limit=1*
 *
 *
 does anyone have a clue what's going on?

 thx


-- 
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

[android-developers] Re: instance count violation

2012-06-07 Thread marcin kolonko
ok, i did some memory digging with ddms and memory analizer. and there' 
s weird behavior:

when i run the garbage collector while in portrait mode (still the same 
case us in first post) and come back to portrait mode, nothing bad happens. 
the app behaves as it should.
when i don't run the garbage collector, the app crashes with the instance 
count violation error.

-- 
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

[android-developers] Re: instance count violation

2012-06-07 Thread marcin kolonko
ok, i did some memory digging with ddms and memory analizer. and there' 
s weird behavior:

when i run the garbage collector while in portrait mode (still the same 
case us in first post) and come back to portrait mode, nothing bad happens. 
the app behaves as it should.
when i don't run the garbage collector, the app crashes with the instance 
count violation error.

On Thursday, June 7, 2012 12:39:58 PM UTC+2, marcin kolonko wrote:

 hi,
 i have an app with two classes:

 *SelectItemActivity** extends **AbstractListActivity,* and *
 AbstractListActivity extends Activity*
 *
 *
 (~20 lines of code each) - not much to screw up i thought...

 links to pastebin:
 *AbstractListActivity* : http://pastebin.com/iKEa3d3a
 *SelectItemActivity : *http://pastebin.com/UC01gvTg
 *Menu*: http://pastebin.com/vjL1r28q

 now, when i click on the button in the actionbar, switch to landscape and 
 then back to portrait, the app crashes and i get this error:
 *android.os.StrictMode$InstanceCountViolation: class 
 ch.futurecom.MeetingMaid.view.SelectItemActivity; instances=2; limit=1*
 *
 *
 does anyone have a clue what's going on?

 thx


-- 
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

Re: [android-developers] Re: instance count violation

2012-06-07 Thread Kostya Vasilyev
I remember seeing this in one of my apps in certain cases.

My conclusion was that this might be a bug in strict mode code, and
disabled it.

Activity orientation changes are processed within a single message loop
heartbeat, so it's entirely possible that the lifecycles of both activity
instances overlap.

-- K

2012/6/7 marcin kolonko makolo...@gmail.com

 ok, i did some memory digging with ddms and memory analizer. and there'
 s weird behavior:

 when i run the garbage collector while in portrait mode (still the same
 case us in first post) and come back to portrait mode, nothing bad happens.
 the app behaves as it should.
 when i don't run the garbage collector, the app crashes with the instance
 count violation error.


-- 
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

Re: [android-developers] Re: instance count violation

2012-06-07 Thread Daniel Drozdzewski
On 7 June 2012 15:06, Kostya Vasilyev kmans...@gmail.com wrote:
 I remember seeing this in one of my apps in certain cases.

 My conclusion was that this might be a bug in strict mode code, and disabled
 it.

 Activity orientation changes are processed within a single message loop
 heartbeat, so it's entirely possible that the lifecycles of both activity
 instances overlap.


+1

Setting launchMode to 'singleInstance' can solve this 'issue', as it
will force each (re)created activity to launch in a separate task.
However the wider issue to consider is that
StrictMode.ThreadPolicy.Builder.detectAll() detects *potential*
problems.

The fact that once GCed the activity dissapears, means that it will
get eventually cleared and is not a leak.


Daniel



 2012/6/7 marcin kolonko makolo...@gmail.com

 ok, i did some memory digging with ddms and memory analizer. and there'
 s weird behavior:

 when i run the garbage collector while in portrait mode (still the same
 case us in first post) and come back to portrait mode, nothing bad happens.
 the app behaves as it should.
 when i don't run the garbage collector, the app crashes with the instance
 count violation error.


 --
 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



-- 
Daniel Drozdzewski

-- 
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


Re: [android-developers] Re: instance count violation

2012-06-07 Thread Kostya Vasilyev
RIght, the activity instance tracker depends on GC to decrement its value.

https://github.com/android/platform_frameworks_base/blob/master/core/java/android/app/Activity.java#L732

https://github.com/android/platform_frameworks_base/blob/master/core/java/android/os/StrictMode.java#L2149

Using onDestroy/onCreate would let the count be more accurate during
orientation changes... but won't track memory leaks caused by Context
references, which probably is a more common issue.

-- K

2012/6/7 Daniel Drozdzewski daniel.drozdzew...@gmail.com

 On 7 June 2012 15:06, Kostya Vasilyev kmans...@gmail.com wrote:
  I remember seeing this in one of my apps in certain cases.
 
  My conclusion was that this might be a bug in strict mode code, and
 disabled
  it.
 
  Activity orientation changes are processed within a single message loop
  heartbeat, so it's entirely possible that the lifecycles of both activity
  instances overlap.


 +1

 Setting launchMode to 'singleInstance' can solve this 'issue', as it
 will force each (re)created activity to launch in a separate task.
 However the wider issue to consider is that
 StrictMode.ThreadPolicy.Builder.detectAll() detects *potential*
 problems.

 The fact that once GCed the activity dissapears, means that it will
 get eventually cleared and is not a leak.


 Daniel


 
  2012/6/7 marcin kolonko makolo...@gmail.com
 
  ok, i did some memory digging with ddms and memory analizer. and there'
  s weird behavior:
 
  when i run the garbage collector while in portrait mode (still the same
  case us in first post) and come back to portrait mode, nothing bad
 happens.
  the app behaves as it should.
  when i don't run the garbage collector, the app crashes with the
 instance
  count violation error.
 
 
  --
  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



 --
 Daniel Drozdzewski

 --
 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


-- 
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

Re: [android-developers] Re: instance count violation

2012-06-07 Thread Dianne Hackborn
On Thu, Jun 7, 2012 at 7:29 AM, Daniel Drozdzewski 
daniel.drozdzew...@gmail.com wrote:

 Setting launchMode to 'singleInstance' can solve this 'issue', as it
 will force each (re)created activity to launch in a separate task.


OMG, do NOT use singleInstance to solve the problem.  This is a very
special launch mode that has major subtle repercussions on the management
and flow of your app that you almost certainly DO NOT WANT.

And to be honest, it would have no impact on what is being reported here (a
problem when rotating) because singleInstance doesn't impact the fact that
the activity is being destroyed and recreated.

-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

-- 
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