Loading ...
Sorry, an error occurred while loading the content.

Re: [linuxham] Re: fldigi 1.02 posted

Expand Messages
  • w1hkj
    ... Yes Jim, that is true. Quite often a function will be used to generate a pointer to a dynamic array. The value of the pointer might then be the return
    Message 1 of 10 , Nov 27, 2006
    • 0 Attachment

      Is it generally true that every "new" should have a matching "delete" ?
      (Unless you want it to stay around until the program terminates.)
        
      Yes Jim, that is true.  Quite often a function will be used to generate a pointer to a dynamic array.  The value of the pointer might then be the return value from the function.  In that case the function would not do the array deletion, but the invoking function or somewhere up the line would eventually.  That type of programming leads to memory leaks much more often than my simplistic error.  I knew better, but was in a hurry when I made the changes that caused the problem.

      Every new has to have a corresponding delete
      Every new <type>[size]  has to have a corresponding delete []

      In the case I quoted in the earlier email, the pointer was created on the stack (part of the program execution memory usually) and the array which it points was created on the heap (usually an entirely different part of memory).  I can send you a very simple memory killer C++ source code that you can try if you want.

      Dave
      
      
      
       
      Yahoo! Groups Links
      
      <*> To visit your group on the web, go to:
          http://groups.yahoo.com/group/linuxham/
      
      <*> Your email settings:
          Individual Email | Traditional
      
      <*> To change settings online go to:
          http://groups.yahoo.com/group/linuxham/join
          (Yahoo! ID required)
      
      <*> To change settings via email:
          mailto:linuxham-digest@yahoogroups.com 
          mailto:linuxham-fullfeatured@yahoogroups.com
      
      <*> To unsubscribe from this group, send an email to:
          linuxham-unsubscribe@yahoogroups.com
      
      <*> Your use of Yahoo! Groups is subject to:
          http://docs.yahoo.com/info/terms/
       
      
      
      
        

    • jhaynesatalumni
      Well far be it from me to be a critic of programming style, and maybe nobody else in this group is interested in the question; but seems like it would be
      Message 2 of 10 , Nov 27, 2006
      • 0 Attachment
        Well far be it from me to be a critic of programming style, and
        maybe nobody else in this group is interested in the question;
        but seems like it would be better to create the new area in the
        same scope where it would be deleted, and then pass a pointer to
        it to the function if the function is going to write on it and then
        leave it there.

        I never was a Real Programmer, but I grew up in the days of Burroughs
        machines and Algol. There the new[] array would be created on the
        stack and would go away when the function was exited. So you would
        have to create it and then call the function to operate on it, and
        when the function got through the array would still be there until
        you exited the block where it was created. Well, actually, the new[]
        array might not be created on the stack; it might be created as a fresh
        segment with a descriptor in the stack. But it would be freed when the
        block that created it exited.

        I guess this is a matter of whether you keep track of everything or
        whether you create things that live beyond their creators and then you
        have to have garbage collection to find the things that are no longer
        pointed to by anybody and delete them.
      • Leigh L Klotz, Jr.
        Anybody for a Java port? Or even C#? Leigh/WA5ZNU
        Message 3 of 10 , Nov 27, 2006
        • 0 Attachment
          Anybody for a Java port? Or even C#?
          Leigh/WA5ZNU
        • Hamish Moffatt
          ... Why? How does the language matter? Hamish -- Hamish Moffatt VK3SB
          Message 4 of 10 , Nov 27, 2006
          • 0 Attachment
            On Mon, Nov 27, 2006 at 07:21:06PM -0800, Leigh L Klotz, Jr. wrote:
            > Anybody for a Java port? Or even C#?

            Why? How does the language matter?

            Hamish
            --
            Hamish Moffatt VK3SB <hamish@...> <hamish@...>
          • Tehrasha Darkon
            ... Well, theoretically a java release would run on any platform, but I would question how well running a near realtime audio processing program inside a
            Message 5 of 10 , Nov 27, 2006
            • 0 Attachment
              --- In linuxham@yahoogroups.com, Hamish Moffatt <hamish@...> wrote:
              >
              > On Mon, Nov 27, 2006 at 07:21:06PM -0800, Leigh L Klotz, Jr. wrote:
              > > Anybody for a Java port? Or even C#?
              >
              > Why? How does the language matter?
              >
              > Hamish
              > --
              > Hamish Moffatt VK3SB <hamish@...> <hamish@...>
              >

              Well, theoretically a java release would run on any platform, but I
              would question how well running a near realtime audio processing
              program inside a virtual machine would work.

              --Teh
            • Leigh L Klotz, Jr.
              I think Java would have fine performance, with either the Sun or IBM JVM implementations. They both compile to native code internally. I suspect that C# and
              Message 6 of 10 , Nov 28, 2006
              • 0 Attachment
                I think Java would have fine performance, with either the Sun or IBM JVM
                implementations. They both compile to native code internally. I
                suspect that C# and its runtime do the same thing.

                I wrote a PSK app for my cell phone in Java, and while it did only the
                display portion of the work, the performance was fine.

                Hamish, this came on the heels of the discussion about language support
                for memory alocation and deallocation, and the Java and C# support for
                GC-based allocation is the point I was making.
                73,
                Leigh/WA5ZNU.
                On Mon, 27 Nov 2006 8:55 pm, Tehrasha Darkon wrote:
                > --- In linuxham@yahoogroups.com, Hamish Moffatt <hamish@...> wrote:
                >>
                >> On Mon, Nov 27, 2006 at 07:21:06PM -0800, Leigh L Klotz, Jr. wrote:
                >> > Anybody for a Java port? Or even C#?
                >>
                >> Why? How does the language matter?
                >>
                >> Hamish
                >> --
                >> Hamish Moffatt VK3SB <hamish@...> <hamish@...>
                >>
                >
                > Well, theoretically a java release would run on any platform, but I
                > would question how well running a near realtime audio processing
                > program inside a virtual machine would work.
                >
                > --Teh
                >
                >
                >
                >
                > Yahoo! Groups Links
                >
                >
                >
              • w1hkj
                ... All of the modem code for fldigi is written using c++ classes. The port to Java should be straight forward Leigh. I am not conversant enough with Java to
                Message 7 of 10 , Nov 28, 2006
                • 0 Attachment
                  Leigh L Klotz, Jr. wrote:

                  >I think Java would have fine performance, with either the Sun or IBM JVM
                  >implementations. They both compile to native code internally. I
                  >suspect that C# and its runtime do the same thing.
                  >
                  >I wrote a PSK app for my cell phone in Java, and while it did only the
                  >display portion of the work, the performance was fine.
                  >
                  >
                  All of the modem code for fldigi is written using c++ classes. The port
                  to Java should be straight forward Leigh. I am not conversant enough
                  with Java to make the attempt. Perhaps you might like to take that on
                  as a personal project. The gui and the h/w io including the soundard
                  would have to be rewritten in Java of course. The most challenging
                  would be the creation of a suitable waterfall widget in Java.

                  Dave, W1HKJ
                • Leigh L Klotz, Jr.
                  Dave, I certainly wasn t suggesting you take it on! Everybody can see how busy -- and how succesful -- you are with fldigi. A digimode Java program has been
                  Message 8 of 10 , Nov 28, 2006
                  • 0 Attachment
                    Dave,
                    I certainly wasn't suggesting you take it on! Everybody can see how
                    busy -- and how succesful -- you are with fldigi.

                    A digimode Java program has been on my list for a long time. I do have
                    the waterfall done, though. I also have an FFT in Java (fixed point)
                    and there are plenty of floating point ones. And recent versions of
                    Java have an abstract sound interface, the Java Sound API.
                    73,
                    Leigh/WA5ZNU
                    On Tue, 28 Nov 2006 8:02 am, w1hkj wrote:
                    > Leigh L Klotz, Jr. wrote:
                    >
                    >> I think Java would have fine performance, with either the Sun or IBM
                    >> JVM
                    >> implementations. They both compile to native code internally. I
                    >> suspect that C# and its runtime do the same thing.
                    >>
                    >> I wrote a PSK app for my cell phone in Java, and while it did only the
                    >> display portion of the work, the performance was fine.
                    >>
                    >>
                    > All of the modem code for fldigi is written using c++ classes. The
                    > port
                    > to Java should be straight forward Leigh. I am not conversant enough
                    > with Java to make the attempt. Perhaps you might like to take that on
                    > as a personal project. The gui and the h/w io including the soundard
                    > would have to be rewritten in Java of course. The most challenging
                    > would be the creation of a suitable waterfall widget in Java.
                    >
                    > Dave, W1HKJ
                    >
                    >
                    >
                    >
                    > Yahoo! Groups Links
                    >
                    >
                    >
                  Your message has been successfully submitted and would be delivered to recipients shortly.