2013/10/2 Maxime Roy <maximeroy...@gmail.com>:
> Memory leaks
>
> I wrote a firmware to read ov7725 camera for cypress FX2LP.
>
> I wrote a code for cypress generic driver on windows -> no leaks
> I wrote a code  libusb_win32 for windows -> no leaks
> I wrote a code for libusbx-1.0.17 in sync mode for ubuntu -> no leaks
>
> But in async mode with libusbx-1.0.17 -> memory leaks
>
> Each time I read a video frame in async mode with libusbx-1.0.1x  it loose
> ~100bytes.
> You can see this leaks in gnome-system-monitor after some time
>
>
> my code is:
>
> void cb_response_in(struct libusb_transfer *transfer){
> int * completed = transfer->user_data;
> *completed  = 1;
> }
>
> int get_frame(unsigned char * data, int len ){
> int r = 0;
> int completed = 0;
>
>
>         unsigned char tmp[1];
>
> //Request a video frame to firmware...
>         r=libusb_control_transfer( devh,
>                                     LIBUSB_REQUEST_TYPE_VENDOR |
> LIBUSB_RECIPIENT_DEVICE | LIBUSB_ENDPOINT_OUT,
>                                     0xA8,
>                                     0x00,
>                                     0,
>                                     tmp,
>                                     0,
>                                     500);
>
>
>         transfer_response_in  = libusb_alloc_transfer(0);

You're calling libusb_alloc_transfer here but you don't call
libusb_free_transfer to free it again. You could also used the
LIBUSB_TRANSFER_FREE_TRANSFER flag instead to make libusb
automatically free the transfer after cb_response_in was called. But
as you don't neither of this the transfer_response_in object leaks.

-- 
Matthias Bolte
http://photron.blogspot.com

------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60134791&iu=/4140/ostg.clktrk
_______________________________________________
libusbx-devel mailing list
libusbx-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libusbx-devel

Reply via email to