Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. need help on memory leak

need help on memory leak

Scheduled Pinned Locked Moved C / C++ / MFC
performancehelpquestion
7 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    houari_id
    wrote on last edited by
    #1

    Dear All... I have problems in avoiding memory leak. I've browsed through the message board regarding memory leak, but still can not find solution. I have this function: void CPA003Dlg::doMultiplyT(double **A, int M) { double temp_Sum = 0; double **B; B = new double *[M]; for (int x=0;x what should I do? thanks...

    T D 2 Replies Last reply
    0
    • H houari_id

      Dear All... I have problems in avoiding memory leak. I've browsed through the message board regarding memory leak, but still can not find solution. I have this function: void CPA003Dlg::doMultiplyT(double **A, int M) { double temp_Sum = 0; double **B; B = new double *[M]; for (int x=0;x what should I do? thanks...

      T Offline
      T Offline
      toxcct
      wrote on last edited by
      #2

      houari_id wrote:

      for (int x=0;x for (x=0;x B[x][0] = A[0][M]; B[x][1] = A[1][M]; }

      houari_id wrote:

      for (int z=0; z temp_Sum += (A[x][z]*B[z][y]); }

      i guess this is not what you wanted to type... so, use the little [Modify] link at the botton of your post and there, uncheck the Ignore HTML tags in this message checkbox... thanks


      TOXCCT >>> GEII power
      [toxcct][VisualCalc]

      C 1 Reply Last reply
      0
      • T toxcct

        houari_id wrote:

        for (int x=0;x for (x=0;x B[x][0] = A[0][M]; B[x][1] = A[1][M]; }

        houari_id wrote:

        for (int z=0; z temp_Sum += (A[x][z]*B[z][y]); }

        i guess this is not what you wanted to type... so, use the little [Modify] link at the botton of your post and there, uncheck the Ignore HTML tags in this message checkbox... thanks


        TOXCCT >>> GEII power
        [toxcct][VisualCalc]

        C Offline
        C Offline
        Cedric Moonen
        wrote on last edited by
        #3

        Mmmhhh, forgot to uncheck the 'Ignore HTML tags' ? :rolleyes:

        T H 2 Replies Last reply
        0
        • H houari_id

          Dear All... I have problems in avoiding memory leak. I've browsed through the message board regarding memory leak, but still can not find solution. I have this function: void CPA003Dlg::doMultiplyT(double **A, int M) { double temp_Sum = 0; double **B; B = new double *[M]; for (int x=0;x what should I do? thanks...

          D Offline
          D Offline
          David Crow
          wrote on last edited by
          #4

          houari_id wrote:

          what should I do?

          Your use of a 2D array is incorrect. Try:

          double **B = new double*[FirstDimension];
          for (int x = 0; x < FirstDimension; x++)
          {

          = new double[SecondDimension];

          for (int y = 0; y < SecondDimension; y++)
          {
          B[x][y] = 0.0; // initialize to some value
          }
          }
          ...
          for (x = 0; x < FirstDimension; x++)
          delete [] B[x];

          delete [] B;


          "Take only what you need and leave the land as you found it." - Native American Proverb

          H 1 Reply Last reply
          0
          • C Cedric Moonen

            Mmmhhh, forgot to uncheck the 'Ignore HTML tags' ? :rolleyes:

            T Offline
            T Offline
            toxcct
            wrote on last edited by
            #5

            arf, nop :D actually, when a Copied/pasted the checkbox caption, i did not see that i checked it... and as CP is so slow some times, you answered before i had the time to uncheck it ;P but it's fixed now ;)


            TOXCCT >>> GEII power
            [toxcct][VisualCalc]

            1 Reply Last reply
            0
            • C Cedric Moonen

              Mmmhhh, forgot to uncheck the 'Ignore HTML tags' ? :rolleyes:

              H Offline
              H Offline
              houari_id
              wrote on last edited by
              #6

              ah... i guess so... ^^;;; sorry..

              1 Reply Last reply
              0
              • D David Crow

                houari_id wrote:

                what should I do?

                Your use of a 2D array is incorrect. Try:

                double **B = new double*[FirstDimension];
                for (int x = 0; x < FirstDimension; x++)
                {

                = new double[SecondDimension];

                for (int y = 0; y < SecondDimension; y++)
                {
                B[x][y] = 0.0; // initialize to some value
                }
                }
                ...
                for (x = 0; x < FirstDimension; x++)
                delete [] B[x];

                delete [] B;


                "Take only what you need and leave the land as you found it." - Native American Proverb

                H Offline
                H Offline
                houari_id
                wrote on last edited by
                #7

                Ah!! It worked!! Thank you very much...

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups