×

Discussion Board

Results 1 to 7 of 7
  1. #1
    Registered User
    Join Date
    Jan 2010
    Posts
    11

    Camera Wrapper wont release image buffer

    I notice that the Camera Wrapper does not release memory for captured bitmaps.

    I added RAM logging to the Camera example to see what is happening.

    I removed everything from the MceoCapturedBitmapReady function except for the code that is supposed to release the buffer, like this;

    Code:
    void CCameraWrapperExampleAppView::MceoCapturedBitmapReady(CFbsBitmap* aBitmap)
    	{
    	__DebugLogRAM("MceoCapturedBitmapReady");
    	
    	TSize bmpSizeInPixels = aBitmap->SizeInPixels();
    	SetTitle(_L("Processing image"));
    
    	aBitmap->Reset();  // not in example, but added
    
    	if (iCameraWrapper) // this should release buffer but doesnt
    		iCameraWrapper->ReleaseImageBuffer();
    
    	}
    The CameraWrapper::PrepareL function immediately claims 6Mb which is the size of the 2Mb RGB image I request.
    The first time MceoCapturedBitmapReady is called, the image is in the 6Mb buffer, but each time I call capture again, the system claims another 6Mb of memory and after 3 calls the application terminates.

    I dont expect the memory to be freed instantly, but the logs show that it is never freed.

    So it is clear that ReleaseImageBuffer does not work. I tried calling aBitmap->Reset()as well, but that has no effect either.

    ReleaseViewFinderBuffer does seem to work. There is no change in memory as viewfinder buffers come in.

    I also tried calling User::CompressAllHeaps. That does not work either, but there is a note somewhere in the Wiki that says it does not work.

    I have read through the documentation for the CCamera class, but there is nothing there on how to delete the buffer either.

    Any one have any ideas? or is the Camera Wrapper a non starter?

    Here is the RAM log
    10/03/2010 14:11:52 ReleaseBackBuffer Free RAM: 19050496
    10/03/2010 14:11:52 CreateBackBufferL Free RAM: 19030016
    10/03/2010 14:11:53 MceoCameraReady Free RAM: 18882560
    .. called PrepareL here for a 2MPix RGB image = 6Mb
    10/03/2010 14:11:54 MceoCameraReady - done Free RAM: 12857344
    10/03/2010 14:11:54 MceoViewFinderFrameReady Free RAM: 12857344
    ... many more the same. Viewfinder buffers are released
    10/03/2010 14:12:00 MceoViewFinderFrameReady Free RAM: 12857344
    10/03/2010 14:12:00 MceoViewFinderFrameReady - capture Free RAM: 12857344
    10/03/2010 14:12:03 MceoCapturedBitmapReady Free RAM: 12812288
    .. first image returned in 6Mb buffer
    10/03/2010 14:12:06 CancelCapturedPicture Free RAM: 12812288
    10/03/2010 14:12:06 MceoViewFinderFrameReady Free RAM: 12640256
    10/03/2010 14:12:06 MceoViewFinderFrameReady Free RAM: 12812288
    ... many more the same
    10/03/2010 14:12:10 MceoViewFinderFrameReady Free RAM: 12812288
    10/03/2010 14:12:10 MceoViewFinderFrameReady Free RAM: 12812288
    10/03/2010 14:12:10 MceoViewFinderFrameReady - capture Free RAM: 12812288
    10/03/2010 14:12:13 MceoCapturedBitmapReady Free RAM: 7049216
    ... 2nd image has consumed an additional 6Mb
    10/03/2010 14:12:15 CancelCapturedPicture Free RAM: 7049216
    .. ReleaseImageBuffer has had no effect
    10/03/2010 14:12:16 MceoViewFinderFrameReady Free RAM: 6877184
    10/03/2010 14:12:16 MceoViewFinderFrameReady Free RAM: 6877184
    10/03/2010 14:12:16 MceoViewFinderFrameReady Free RAM: 7049216
    10/03/2010 14:12:16 MceoViewFinderFrameReady Free RAM: 7049216
    ... many more the same
    10/03/2010 14:12:18 MceoViewFinderFrameReady Free RAM: 7049216
    10/03/2010 14:12:18 MceoViewFinderFrameReady Free RAM: 7049216
    10/03/2010 14:12:18 MceoViewFinderFrameReady - capture Free RAM: 7049216
    10/03/2010 14:12:21 MceoCapturedBitmapReady Free RAM: 1282048
    ... 2nd picture has consumed an additional 6Mb leaving only 1Mb
    ... application terminated

  2. #2
    Registered User
    Join Date
    Jan 2010
    Posts
    11

    Re: Camera Wrapper wont release image buffer

    As an experiment, I tried removing the call to

    iCameraWrapper->ReleaseViewFinderBuffer();

    in
    void CCameraWrapperExampleAppView::MceoViewFinderFrameReady(CFbsBitmap& aFrame)

    The logs show that this function does not have any effect either. RAM usage stays the same even though the frame is not released.

    It looks as though neither ReleaseViewFinderBuffer nor ReleaseImageBuffer have any effect, but while the system takes care of viewfinder buffers itself, there must be some undocumented trick to release the image buffer.

    Here is the log
    10/03/2010 14:59:19 MceoViewFinderFrameReady Free RAM: 12726272
    10/03/2010 14:59:19 MceoViewFinderFrameReady Free RAM: 12726272
    10/03/2010 14:59:19 MceoViewFinderFrameReady Free RAM: 12726272
    10/03/2010 14:59:19 MceoViewFinderFrameReady Free RAM: 12726272
    10/03/2010 14:59:20 MceoViewFinderFrameReady Free RAM: 12726272
    10/03/2010 14:59:20 MceoViewFinderFrameReady Free RAM: 12726272
    10/03/2010 14:59:20 MceoViewFinderFrameReady Free RAM: 12726272
    10/03/2010 14:59:20 MceoViewFinderFrameReady Free RAM: 12726272
    10/03/2010 14:59:20 MceoViewFinderFrameReady Free RAM: 12726272
    10/03/2010 14:59:20 MceoViewFinderFrameReady Free RAM: 12726272
    10/03/2010 14:59:20 MceoViewFinderFrameReady Free RAM: 12726272

  3. #3
    Registered User
    Join Date
    Jan 2010
    Posts
    11

    Re: Camera Wrapper wont release image buffer

    As another experiment,
    I tried calling PrepareL after each capture.

    Prepare preallocates another 6Mb chunk of memory, but it does not release the previous memory either.

  4. #4
    Registered User
    Join Date
    Jan 2010
    Posts
    11

    Re: Camera Wrapper wont release image buffer

    It seems that ReleaseImageBuffer DOES work if the image format is jpeg.
    Furthermore, if the image is jpeg and ReleaseImageBuffer is not called then memory slowly leaks.
    So ReleaseImageBuffer only works for descriptors in the camera wrapper, not bitmaps.

    I suppose one workaround is to ask for the image in jpeg, and then decode it to a bitmap. That uses more memory, because i will need both the descriptor and the bitmap. It also means I will get a bitmap with jpeg artifacts in it, but at least I can release the bitmap when I have finished with it.

    Another possibility is to junk the camera wrapper and just target Version 5, but I dont know if the Camera engine works properly in version 5 either.

    Has anyone managed to get the camera to return bitmaps? Either with the wrapper or without?

  5. #5
    Registered User
    Join Date
    May 2008
    Location
    Surat Thani
    Posts
    260

    Re: Camera Wrapper wont release image buffer

    Quote Originally Posted by aporter View Post
    Another possibility is to junk the camera wrapper and just target Version 5, but I dont know if the Camera engine works properly in version 5 either.

    Has anyone managed to get the camera to return bitmaps? Either with the wrapper or without?
    Hi,

    I have been capturing CFbsBitmap images directly using CCamera, through both MCameraObserver and MCameraObserver2 callbacks, and haven't at least noticed any memory problems. Also, I would be surprised, if there was a previously unnoticed problem this serious in the camera API level.

    Which device(s) do you see the problem with? The captured images are internally given in a different way, depending on whether the device supports CCamera::New2L (>=3rd FP2) or not (<=3rd FP1), and it's possible that CameraWrapper has a problem only in handling either of them. If you have a chance, give it a try with a device from from the other category.

    If you can't get CameraWrapper working, I guess the only reasonable thing to do is to ditch it and implement camera handling yourself. I've started a blog on using New2L/CCameraAdvancedSettings functionality in a backwards-compatible way - it might be of interest, if you want to support autofocus for both device categories in the same binary without CameraWrapper. Nothing practical there yet, but more info will probably appear some point soon:

    http://tcamerainfo.blogspot.com/

    -TongMuan

  6. #6
    Registered User
    Join Date
    Jan 2010
    Posts
    11

    Re: Camera Wrapper wont release image buffer

    Hi TongMuan,

    I am testing against a 3rd MR device. It is possible that the wrapper works with other devices of course. However, searching the forums, I notice that other people have encountered the same problem. Someone encountered a memory leak in the camera wrapper example and proposed a solution but the example was never fixed.

    I also had a lot of trouble just installing the camera wrapper on the phone. Installation would seem to go OK but the application would just fail trying to instantiate it.

    On the OVI store I see that many reviews of camera based applications say that after payment and download, the app just doesnt work, and I suspect the camera wrapper might be involved.

    So it would seem prudent to ditch the camera wrapper

  7. #7
    Registered User
    Join Date
    Nov 2008
    Location
    Australia
    Posts
    88

    Re: Camera Wrapper wont release image buffer

    Hi aporter,

    I am impressed with your debugging technique and I was wondering if you would be prepared to share your code that provided this capability as I am a bit of a novice

    Cheers
    David4x

Similar Threads

  1. Replies: 0
    Last Post: 2010-01-07, 07:04
  2. Replies: 5
    Last Post: 2009-07-20, 18:41
  3. How to change default camera image in S40 5th edition?
    By asahlot in forum Mobile Java Media (Graphics & Sounds)
    Replies: 2
    Last Post: 2008-11-01, 00:37
  4. image on camera Canvas
    By mshouab in forum Mobile Java Media (Graphics & Sounds)
    Replies: 29
    Last Post: 2008-09-29, 08:52
  5. Camera Image Quality
    By ronald29 in forum Symbian Media (Closed)
    Replies: 7
    Last Post: 2006-07-21, 10:43

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×