[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[linrad] Re: Memory leakage.
- Subject: [linrad] Re: Memory leakage.
- From: Leif Asbrink <sm5bsz.com; leif@xxxxxxxxxxxxxxxx>
- Date: Wed, 19 Apr 2006 14:04:48 +0200
Hi Richard,
> I cant speak as an accomplished programmer, having only done simple
> projects in C++
> Still the code seems to be part of a routine. It looks like
>
> cross_cursor is an object of class XCreateFontCursor
Yes. XCreateFontCursor allocates memory to a pointer but
XFreeCursor frees the memory again.
If I omit XFreeCursor, valgrind reports some still reachable
leakage but the number of definitely lost memory stays the same.
> Maybe this is not being destroyed after use?
>
> I havent the faintest how you would find the class code for this
> X11 on my machine appears to be all C, though I cant locate
> source - I have just loaded Mandrake from a CD
I do not understand what "the class code for this" means.
Not at all being a programmer I become confused.
When reading about C++ (which I find alien and impractical)
I get the impression that Class is simply a data structure,
a list of variables that could contain data or pointers
to data, pointers or routines.
It seems to me that XCreateFontCursor does not only allocate
memory to cross_cursor which I can free with XFreeCursor,
it must also allocate something else - maybe routines needed
by the pointers to routines in the list of pointers constituting
the data of cross_cursor. My problem is that I can not find out
whether I should call some XCloseCursorThings (or whatever) after
having freed the last cursor. Finding XFreeCursor was not
a trivial thing. One would expect the man page about
XCreateFontCursor to give a hint - but it does not:-(
I was hoping someone could tell me proper name of
XCloseCursorThings if something like that exists - or
tell me that the code below is perfectly correct and complete
and that I should disregard the valgrind output.
73
Leif / SM5BSZ
>
> No doubt there are more accomplished programmers who could advise..
>
> Richard
>
>
> Leif Asbrink wrote:
>
> >Hello Richard,
> >
> >
> >
> >>Lost memory is allocated when an object in C++ is created , but not
> >>released when the object is destroyed. This is usually performed by the
> >>destructor for the class if the class has been written properly.
> >>
> >>
> >???????????????
> >I have seen similar text before, but it does not tell me anything
> >at all. I have for example this problem. Only four simple statements:
> >
> >xdis = XOpenDisplay(":0");
> >cross_cursor = XCreateFontCursor(xdis, XC_diamond_cross);
> >XFreeCursor(xdis, cross_cursor);
> >XCloseDisplay(xdis);
> >return 0;
> >
> >If I comment out the second and the third statement all is ok,
> >but with both of them in place I get this report from valgrind:
> >==9031== LEAK SUMMARY:
> >==9031== definitely lost: 8 bytes in 1 blocks.
> >==9031== indirectly lost: 104 bytes in 4 blocks.
> >
> >
> >
> >>This results in increasing useless RAM utilization and eventually disk
> >>swapping, slowing everything down.
> >>
> >>
> >How can I detect whether it happened?
> >
> >
> >
> >>(hope I am not telling you things you already know.. :) )
> >>
> >>
> >You told things I kind of heard about but that I do not
> >understand how to deal with. Did I make a mistake in the
> >example above or is X11 not quite ok yet? Do you know?
> >Using pthreads is much worse..............
> >
> >73
> >
> >Leif
> >
> >
> >#############################################################
> >This message is sent to you because you are subscribed to
> > the mailing list <linrad@xxxxxxxxxxxxxxxxxxxxx>.
> >To unsubscribe, E-mail to: <linrad-off@xxxxxxxxxxxxxxxxxxxxx>
> >To switch to the DIGEST mode, E-mail to <linrad-digest@xxxxxxxxxxxxxxxxxxxxx>
> >To switch to the INDEX mode, E-mail to <linrad-index@xxxxxxxxxxxxxxxxxxxxx>
> >Send administrative queries to <linrad-request@xxxxxxxxxxxxxxxxxxxxx>
> >
> >
> >
>
> #############################################################
> This message is sent to you because you are subscribed to
> the mailing list <linrad@xxxxxxxxxxxxxxxxxxxxx>.
> To unsubscribe, E-mail to: <linrad-off@xxxxxxxxxxxxxxxxxxxxx>
> To switch to the DIGEST mode, E-mail to <linrad-digest@xxxxxxxxxxxxxxxxxxxxx>
> To switch to the INDEX mode, E-mail to <linrad-index@xxxxxxxxxxxxxxxxxxxxx>
> Send administrative queries to <linrad-request@xxxxxxxxxxxxxxxxxxxxx>
>
#############################################################
This message is sent to you because you are subscribed to
the mailing list <linrad@xxxxxxxxxxxxxxxxxxxxx>.
To unsubscribe, E-mail to: <linrad-off@xxxxxxxxxxxxxxxxxxxxx>
To switch to the DIGEST mode, E-mail to <linrad-digest@xxxxxxxxxxxxxxxxxxxxx>
To switch to the INDEX mode, E-mail to <linrad-index@xxxxxxxxxxxxxxxxxxxxx>
Send administrative queries to <linrad-request@xxxxxxxxxxxxxxxxxxxxx>
LINRADDARNIL