Memory leaking..

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jack Klein

    #16
    Re: Memory leaking..

    On Thu, 15 Nov 2007 01:58:44 -0800 (PST), "dSpam@arcor.de "
    <dSpam@arcor.de wrote in comp.lang.c:
    On 15 Nov., 08:20, Ian Collins <ian-n...@hotmail.co mwrote:
    gNash wrote:
    what it mean?
    I've no idea, never having used valgrind. All I can say is it is wrong.
    >
    If you've no idea what something means, you cannot know that it is
    wrong. (But of course you can say it regardless.)
    Yes, he can. As far as the C language is concerned, and that's the
    only thing that counts here, free() was properly called on a pointer
    returned from malloc(). Since the free() function cannot fail if
    called correctly, as it is in this case, the memory was freed.

    Neither Ian nor I have to know much about valgrind, the Magna Carta,
    or a Comcast commercial featuring the Slowskys, to state that if they
    say this memory was not freed, the are wrong.

    The memory was freed in the only context that matters in this group.

    --
    Jack Klein
    Home: http://JK-Technology.Com
    FAQs for
    comp.lang.c http://c-faq.com/
    comp.lang.c++ http://www.parashift.com/c++-faq-lite/
    alt.comp.lang.l earn.c-c++

    Comment

    • Pietro Cerutti

      #17
      Re: Memory leaking..

      Richard Heathfield wrote:
      [5] - if logic were any guide, it would make sense for memcpy to perform
      the copy faster than strcpy.
      Which logic would say so?


      --
      Pietro Cerutti

      PGP Public Key:

      Comment

      • Richard Heathfield

        #18
        Re: Memory leaking..

        Pietro Cerutti <gahr_AT_gahr_D OT_ch_DO_NOT_SP AMsaid:
        Richard Heathfield wrote:
        >[5] - if logic were any guide, it would make sense for memcpy to perform
        >the copy faster than strcpy.
        >
        Which logic would say so?
        With memcpy, you know the length in advance, so you can perform
        optimisations such as copying four, eight, or even more bytes at a time,
        whereas with strcpy that's a lot harder because you have to check for the
        null terminator all the time. So you'd *expect* memcpy to be faster. In
        practice, it need not be, and sometimes isn't.

        --
        Richard Heathfield <http://www.cpax.org.uk >
        Email: -http://www. +rjh@
        Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
        "Usenet is a strange place" - dmr 29 July 1999

        Comment

        • Philip Potter

          #19
          Re: Memory leaking..

          Jack Klein wrote:
          On Thu, 15 Nov 2007 01:58:44 -0800 (PST), "dSpam@arcor.de "
          <dSpam@arcor.de wrote in comp.lang.c:
          >
          >On 15 Nov., 08:20, Ian Collins <ian-n...@hotmail.co mwrote:
          >>gNash wrote:
          >>>what it mean?
          >>I've no idea, never having used valgrind. All I can say is it is wrong.
          >If you've no idea what something means, you cannot know that it is
          >wrong. (But of course you can say it regardless.)
          >
          Yes, he can. As far as the C language is concerned, and that's the
          only thing that counts here, free() was properly called on a pointer
          returned from malloc(). Since the free() function cannot fail if
          called correctly, as it is in this case, the memory was freed.
          >
          Neither Ian nor I have to know much about valgrind, the Magna Carta,
          or a Comcast commercial featuring the Slowskys, to state that if they
          say this memory was not freed, the are wrong.
          >
          The memory was freed in the only context that matters in this group.
          But it didn't say it wasn't freed, it said it was "still reachable".
          That means "No memory leak" in valgrind terms.

          --
          Philip Potter pgp <atdoc.ic.ac. uk

          Comment

          • dSpam@arcor.de

            #20
            Re: Memory leaking..

            On 16 Nov., 04:44, Jack Klein <jackkl...@spam cop.netwrote:
            On Thu, 15 Nov 2007 01:58:44 -0800 (PST), "dS...@arcor.de "
            <dS...@arcor.de wrote in comp.lang.c:
            If you've no idea what something means, you cannot know that it is
            wrong. (But of course you can say it regardless.)
            >
            Yes, he can. As far as the C language is concerned, ...
            May I suggest that you think this over? I maintain that my statement
            above is true in every context, be it the C language or anything else.

            Comment

            • Richard Heathfield

              #21
              Re: Memory leaking..

              Jack Klein said:
              On Thu, 15 Nov 2007 01:58:44 -0800 (PST), "dSpam@arcor.de "
              <dSpam@arcor.de wrote in comp.lang.c:
              >
              >On 15 Nov., 08:20, Ian Collins <ian-n...@hotmail.co mwrote:
              gNash wrote:
              what it mean?
              >
              I've no idea, never having used valgrind. All I can say is it is
              wrong.
              >>
              >If you've no idea what something means, you cannot know that it is
              >wrong. (But of course you can say it regardless.)
              >
              Yes, he can.
              No, he can't.
              As far as the C language is concerned, and that's the
              only thing that counts here, free() was properly called on a pointer
              returned from malloc(). Since the free() function cannot fail if
              called correctly, as it is in this case, the memory was freed.
              Indeed.
              Neither Ian nor I have to know much about valgrind, the Magna Carta,
              or a Comcast commercial featuring the Slowskys, to state that if they
              say this memory was not freed, the are wrong.
              So what you're really saying is that, if you *do* know what something
              means, you can know that it is wrong.
              The memory was freed in the only context that matters in this group.
              Nobody disputes that (AFAIK!).

              --
              Richard Heathfield <http://www.cpax.org.uk >
              Email: -http://www. +rjh@
              Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
              "Usenet is a strange place" - dmr 29 July 1999

              Comment

              • Chris Dollin

                #22
                Re: Memory leaking..

                dSpam@arcor.de wrote:
                On 16 Nov., 04:44, Jack Klein <jackkl...@spam cop.netwrote:
                >On Thu, 15 Nov 2007 01:58:44 -0800 (PST), "dS...@arcor.de "
                ><dS...@arcor.d ewrote in comp.lang.c:
                If you've no idea what something means, you cannot know that it is
                wrong. (But of course you can say it regardless.)
                >>
                >Yes, he can. As far as the C language is concerned, ...
                >
                May I suggest that you think this over? I maintain that my statement
                above is true in every context, be it the C language or anything else.
                You can know that what something /says/ is false, but have independent
                evidence that the said thing is [taken to be] true. From this you may
                conclude that it doesn't mean what it says, and so you've no idea what
                it means. But you do know that what it says is wrong.

                --
                Chris "the application to standards is obvious" Dollin

                Hewlett-Packard Limited Cain Road, Bracknell, registered no:
                registered office: Berks RG12 1HN 690597 England

                Comment

                • Tor Rustad

                  #23
                  Re: Memory leaking..

                  Richard Heathfield wrote:
                  Jack Klein said:
                  [...]
                  >The memory was freed in the only context that matters in this group.
                  >
                  Nobody disputes that (AFAIK!).
                  Why, isn't static storage duration of string literals relevant?

                  Methinks valgrind reported this:

                  char *str="Five pineapples";

                  --
                  Tor <bwzcab@wvtqvm. vw | tr i-za-h a-z>

                  Comment

                  • J. J. Farrell

                    #24
                    Re: Memory leaking..

                    Jack Klein wrote:
                    On Thu, 15 Nov 2007 01:58:44 -0800 (PST), "dSpam@arcor.de "
                    <dSpam@arcor.de wrote in comp.lang.c:
                    >
                    >On 15 Nov., 08:20, Ian Collins <ian-n...@hotmail.co mwrote:
                    >>gNash wrote:
                    >>>what it mean?
                    >>I've no idea, never having used valgrind. All I can say is it is wrong.
                    >If you've no idea what something means, you cannot know that it is
                    >wrong. (But of course you can say it regardless.)
                    >
                    Yes, he can. As far as the C language is concerned, and that's the
                    only thing that counts here, free() was properly called on a pointer
                    returned from malloc(). Since the free() function cannot fail if
                    called correctly, as it is in this case, the memory was freed.
                    >
                    Neither Ian nor I have to know much about valgrind, the Magna Carta,
                    or a Comcast commercial featuring the Slowskys, to state that if they
                    say this memory was not freed, the are wrong.
                    Something of a straw man, Jack. Whoever said that the memory was not
                    freed? Valgrind reportedly said "16 byts (sic) in 1 block still
                    reachable". Does that have anything to do with memory being freed? I
                    don't know. I have no idea what it means. I don't know whether or not it
                    is wrong, since I don't know what it is trying to say. Ian appears to be
                    in much the same position as me, since when asked what it means he said
                    "I've no idea, never having used valgrind". However, he went on to say
                    that the message was wrong. Since he does not know what the message
                    means he cannot know it is wrong, and is wrong to say that it is wrong.
                    For all that you, I, or Ian know, it might be Valgrind's obscure way of
                    saying "all memory allocated by malloc() has been correctly freed".
                    The memory was freed in the only context that matters in this group.
                    The OP's question may be off-topic, but that doesn't impinge on whether
                    or not the message was wrong; it impinges on our ability to say whether
                    or not the message was wrong.

                    Comment

                    Working...