Android Camera Garbage Collection.

by Karan Parikh » Wed, 27 May 2009 03:47:10 GMT


Sponsored Links
 Hey All,
      I am developing a camera application , where the frame rate is
important. However, camera uses a preview callback function which
allocates a byte[] array of 230400 bytes, which makes it necessary for
the garbage collection to step in. Can someone suggest me a way to
avoid garbage collection stepping in ?
Thanks in advance.
Regards,
Karan.


--~--~---------~--~----~------------~-------~--~----~



Android Camera Garbage Collection.

by Robert Green » Wed, 27 May 2009 04:14:14 GMT


 Are you talking about the method Camera.PreviewCallback.onPreviewFrame
(byte[] arg0, anrdoid.hardware.Camera arg1) ?

Is it allocating a new byte[] for every call?

I would think it would keep its same byte[] and reuse it for each
call.

Posting more code may help.  Thanks



--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


Android Camera Garbage Collection.

by Tom Gibara » Wed, 27 May 2009 04:17:46 GMT


 I'm pretty sure I have looked into this in the past and found that a
different object reference is supplied on each call.
Tom.

2009/5/26 Robert Green <rbgrn....@gmail.com>



--~--~---------~--~----~------------~-------~--~----~



Android Camera Garbage Collection.

by Bo » Wed, 27 May 2009 07:19:13 GMT


 I would like to know that as well. According to the log, garbage
collector is freeing the byte array on every callback. It's a big
waste of time.

Best,

Bo



--~--~---------~--~----~------------~-------~--~----~



Android Camera Garbage Collection.

by karan parikh » Thu, 28 May 2009 13:26:11 GMT


 Hey All,
      @Robert: Yes. I am talking about the same function call. If you read
the documentation for that, It says that a new copy is assigned everytime.
You could also verify it with the allocation tracker. It is assigning that
memory multiple times.
      @Tom: Yes a new object reference is supplied each time.
My suggestions:
1. We could implement a different jar file so that the frame gets
overwritten everytime. But then I believe this would remove the portability
from the application.
2. We can change the garbage collector or play around with the memory
allocation for that very thread. I believe each thread has a generational
gc. We could further look into that. We could overwrite the memory for that
particular allocation each time, rather than freeing it and reallocating the
same.
3. We can ask some one from google to look into it directly and create an
issue, which I will be doing by tonight.
Please let me know your suggestions to remove this bottleneck.
Thanks for commenting.
Regards,
Karan.







-- 
Regards,
-Karan.

--~--~---------~--~----~------------~-------~--~----~



Android Camera Garbage Collection.

by Mike Hearn » Thu, 28 May 2009 22:17:07 GMT


 If you want to distribute the app to existing Android phone owners,
you're out of luck. You'll have to file a bug.

How does the Camera app itself handle this situation?

--~--~---------~--~----~------------~-------~--~----~



Android Camera Garbage Collection.

by Robert Green » Thu, 28 May 2009 23:49:29 GMT


 Have you guys tested it previewing to a surfaceview instead?  I'm
wondering if it doesn't behave differently there.





--~--~---------~--~----~------------~-------~--~----~



Android Camera Garbage Collection.

by Robert Green » Thu, 28 May 2009 23:55:18 GMT


 Karan,

Option 1 is no good - only stubs are in Android.jar for things like
that.  Most of that code is native.  You'd need a custom build of
Android.  If it was just an issue of java, you could write your own
code but since it's native, you're right, portability is the problem.

Option 2 is no good - You can't really change the GC and you can't
really control memory allocation for the thread.  The fact of the
matter is that 284k is being allocated for every frame in native code,
and no amount of messing with stuff is going to change that.

Option 3 works.

Option 4 could be trying alternative ways of getting that data more
efficiently.  I was thinking that running it through a surfaceview and
manipulating its bitmap might work.  It's certainly a hack but it's
worth a shot.





--~--~---------~--~----~------------~-------~--~----~



Android Camera Garbage Collection.

by Bo » Fri, 29 May 2009 06:28:12 GMT


 n May 28, 11:54pm, Robert Green <rbgrn....@gmail.com> wrote:

I don't think this option 4 really works. The surfaceholder must be
set to SURFACE_TYPE_PUSH_BUFFERS to get camera preview. This would
create "a surface that doesn't owns its buffers. With such a surface
lockCanvas will fail."

Best,

Bo

--~--~---------~--~----~------------~-------~--~----~



Android Camera Garbage Collection.

by karan parikh » Fri, 29 May 2009 10:37:17 GMT


 ey,
I have created the issue. It is Issue number 2794. Please look at it
and add extra comments if necessary. I agree with Bo, It is not possible to
do the option number 4. I think there are some changes that are required to
be incorporated in the jar file or provide us with a new API.
Regards,
Karan.

On Thu, May 28, 2009 at 3:27 PM, Bo <wang.b.fr...@gmail.com> wrote:



--
Regards,
-Karan.

--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. Alarm not triggered after restart.

Hi

I get stuck with something that , I guess , is very trivial.

Basically I am scheduling alarm for a given moment in the future :

     Intent contentIntent = new Intent(this, AlarmReceiver.class);

     PendingIntent theappIntent =
PendingIntent.getBroadcast(Main.this, 0,contentIntent, 0);

     Calendar calendar = Calendar.getInstance();
     calendar.set(year, month, day, hour,minute);

     AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE);
     am.set(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(),
theappIntent);

works fine while mobile is constantly on.

My problem is that alarm is not triggered after mobile is restarted
and is TURNED ON on the expected time.

Is there something I missed? Should I do some extra work to keep alarm
scheduled after restart?

regards
m

--

2. help installing ADT eclipse Plugin

Hello,

I tried following the installation steps on 
http://developer.android.com/sdk/eclipse-adt.html
but i get the following errors when i reach the last step.

The error i get is the following:
Cannot complete the install because one or more required items could
not be found.
  Software being installed: Android Development Tools
0.9.5.v200911191123-20404 (com.android.ide.eclipse.adt.feature.group
0.9.5.v200911191123-20404)
  Missing requirement: Android Development Tools
0.9.5.v200911191123-20404 (com.android.ide.eclipse.adt.feature.group
0.9.5.v200911191123-20404) requires 'org.eclipse.wst.xml.ui 0.0.0' but
it could not be found

FYI, I tried all three different ways even downloading the archive and
installing it manually but unfortunately no luck. How do you fix this?

--

3. Load new OS on a Droid or Hero?

4. Gagal Upgrade Rom dan Muncul Tulisan . . . . . Ada Yang Bisa bantu?

5. How does Category_Home intent work ?

6. samsung spica owner anyone?

7. test adr..