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. Already set up G1 (unlocked) with Gmail account now I want to set it up to use my "Google Apps" custom domain acct

A few questions:

1. I aready set up my G1 with my @gmail.com account but now I want to
set it up with my @mydomain.com account that is hosted in Google Apps.

2. How can I set up so that it uses my Google Apps email account
(custom domain) for email and my gmail for  Google Calendar/Google
Voice?

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

2. .apk file failed to uploan on emulator

Hi,
I tried to run the JetBoy sample example from SDK. When i try to run it on
emulator, it gives me following error

[2009-06-08 22:25:50 - JetBoy] Uploading JetBoy.apk onto device
'emulator-5554'

[2009-06-08 22:26:08 - JetBoy] Failed to upload JetBoy.apk on
'emulator-5554': timeout

[2009-06-08 22:26:08 - JetBoy] Launch canceled!

Can anyone tell me what would be the issue.

I am using Android 1.5 platform.  and

<uses-sdk android:minSdkVersion=*"3"* />

Thanks in advance.

-- 
Thanks and Regards
Chinnadurai M

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

3. How to manually change GSM operator (carrier)

4. Can I add a data column to the Contacts db?

5. Can I add a data column to the Contacts db?

6. Launching Settings

7. How to build opercore outside Android?