Coder Social home page Coder Social logo

Comments (15)

TIS-Edgar avatar TIS-Edgar commented on May 23, 2024

Hi there,

The registration of the callback should definitely only be done once (when you setup the camera).
The loop you are using should only be used for the actual work (image snapping, camera change, etc.).

You can of course also try to disconnect existing callbacks:
https://developer.gnome.org/gobject/stable/gobject-Signals.html#g-signal-handlers-disconnect-by-func

As a general approach that might help with all kinds of problems:
you can use valgrind to detect where and how a program leaks memory.
Be aware that certain libraries and programs allocate memory that makes it unclear as to how some memory is freed. Glib and therefor aravis are sadly participating in this behavior. A glib suppression file can help reduce the number of false positives.

from tiscamera.

hanabata avatar hanabata commented on May 23, 2024

Hi,

I use valgrind and I found a large memory leak. The log corresponding to
that part is below.

==13446== 1,226,342,400 bytes in 998 blocks are still reachable in loss
record 1,236 of 1,236
==13446== at 0x4C2AB80: malloc (in
/usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==13446== by 0x5627610: g_malloc (in
/lib/x86_64-linux-gnu/libglib-2.0.so.0.4002.0)
==13446== by 0x4E6044E: arv_buffer_new_full (arvbuffer.c:74)
==13446== by 0x402149: camera_motion (arvcameratest.c:496)
==13446== by 0x401873: main (arvcameratest.c:743)

The memory leakage increase if I increase the loop number. In the function
"camera_motion", I make the loop which the camera takes a snapshot with a
software trigger. This function is called in main function. So I guess
arv_buffer_new_full or camera_motion make the large portion of the leakage.
But I don't know how arv_cbuffer_new_full is used. Is there any possibility
that this function use the large amount of memory? Is it also related to
new_buffer_cb function?

In the camera_motion, I set the callback function for new_buffer_cb as
below.
g_signal_connect (stream, "new-buffer", G_CALLBACK (new_buffer_cb), &data);

So I try to disconnect the callback functions as below.
g_signal_handlers_disconnect_by_func(stream,new_buffer_cb,&data);
But this does reduce the leakage. I also tried "new-buffer" in stead of
new_buffer_cb but I got the same result.
How to use this function?

Cheers,

2014-12-12 18:50 GMT+09:00 Edgar [email protected]:

Hi there,

The registration of the callback should definitely only be done once (when
you setup the camera).
The loop you are using should only be used for the actual work (image
snapping, camera change, etc.).

You can of course also try to disconnect existing callbacks:

https://developer.gnome.org/gobject/stable/gobject-Signals.html#g-signal-handlers-disconnect-by-func

As a general approach that might help with all kinds of problems:
you can use valgrind to detect where and how a program leaks memory.
Be aware that certain libraries and programs allocate memory that makes it
unclear as to how some memory is freed. Glib and therefor aravis are sadly
participating in this behavior. A glib suppression file can help reduce the
number of false positives.

Reply to this email directly or view it on GitHub
#22 (comment)
.

from tiscamera.

TIS-Edgar avatar TIS-Edgar commented on May 23, 2024

Hi,

Could you show me the code of capture_motion and your loop? Maybe that can clear some things up.

Thank you in advance.

from tiscamera.

hanabata avatar hanabata commented on May 23, 2024

Hi,

How do I send the program? Could you teach me your email adress?

from tiscamera.

TIS-Edgar avatar TIS-Edgar commented on May 23, 2024

[email protected]

from tiscamera.

hanabata avatar hanabata commented on May 23, 2024

Hi,

I sent out the program to the email address which you gave me but I got the
email from the Japanese agency that they cannot take care of this problem
because original program was made by third party (ARAVIS). How should I do?

Cheers,

from tiscamera.

TIS-Michael avatar TIS-Michael commented on May 23, 2024

Hello,

did you receive a ticket number?
If you send me the ticket number I can take a look at the case.

from tiscamera.

hanabata avatar hanabata commented on May 23, 2024

Hi,

I didn't receive any ticket. I sent it out with the subject "Memory leakage in the program modified from arvcameratest.c" at 16:43 on 13th in JST.

Cheers,

from tiscamera.

TIS-Michael avatar TIS-Michael commented on May 23, 2024

Hi,

at first glance it seems to me that, as TIS-Edgar pointed out in his first answer, the lines 491

g_signal_connect (stream, "new-buffer", G_CALLBACK (new_buffer_cb), &data);

and 496

g_signal_connect (arv_camera_get_device (camera), "control-lost", G_CALLBACK (control_lost_cb), NULL);

are executed in a loop, thus probably leaking memory.
Are the callbacks freed up again in another part of the code that I did not see?
If not, could you put the lines outside of the loop and run the test again?

from tiscamera.

hanabata avatar hanabata commented on May 23, 2024

Hi,

The loop is made to handle all cameras one after another sequentially. In the loop, each camera takes a snapshot, readouts and analyzes the data.
In the callback functions,
g_signal_connect (stream, "new-buffer", G_CALLBACK (new_buffer_cb), &data)
includes the camera information in the 1st argument "stream".

g_signal_connect (arv_camera_get_device (camera), "control-lost", G_CALLBACK (control_lost_cb), NULL);
includes the information in the 1st argument "arc_camera_get_device".

So I think it's difficult to move the functions to outside the loop if I am correct. If I misunderstand, please correct me.

Cheers,=

from tiscamera.

TIS-Michael avatar TIS-Michael commented on May 23, 2024

Hi,

In that case, you could use a global variable for testing in order to check if the functions were called already.

from tiscamera.

hanabata avatar hanabata commented on May 23, 2024

Hi,

In that case, you could use a global variable for testing in order to check if the functions were called already.

Sorry, I could not get what you mean. Could you please explain a bit more how to do?

Cheers,=

from tiscamera.

hanabata avatar hanabata commented on May 23, 2024

Hi,

I've just tested if only defining the callback function, g_signal_connect (stream, "new-buffer", G_CALLBACK (new_buffer_cb), &data), in the first loop works to retrieve from the camera buffer in the latter loop. Then I found that it is not enough. Here, I used only one camera. Below is the method that I used,

in the function "camera_motion" (see around line. 491 in cap_kt_board20141222.c)

if (call == 0){
g_signal_connect (stream, "new-buffer", G_CALLBACK (new_buffer_cb), &data)
}
call++;

"call" is defined as a global variable. In the original program, this callback function is defined every time when the camera takes a snapshot. So I changed to define this callback function only in the first loop. But this method does not work.
How should I do?

Cheers,

from tiscamera.

TIS-Stefan avatar TIS-Stefan commented on May 23, 2024

Hello

Sorry for the delay of my answer

I searched a little bit in the internet and found this sample:
http://code.metager.de/source/xref/gnome/DevelopmentTools/aravis/tests/arvexample.c

It looks like your sample. I guess, you used it too.

Some annotations:
As far as I know, it is totally wrong to do
g_signal_connect (stream, "new-buffer", G_CALLBACK (new_buffer_cb), &data)
more than once.
Move it out of the look you use in you main() function at while(cap_check<10){...}
The trick is setting up the Aravis library and callbacks and camera. Then you run the software trigger in the loop. If the loop has ended you clean up the Aravis and other things.

from tiscamera.

TIS-Stefan avatar TIS-Stefan commented on May 23, 2024

Closed since there are no more answers.

from tiscamera.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.