Question Memory Leakage while using C# dll in Cpp

videodev

New member
Joined
Dec 10, 2013
Messages
2
Programming Experience
1-3
Dear All,

I have created a C-Sharp dll which parse rtf file and give me text of it using RichTextEdit.


and I am using this dll in my MFC code using Interop.


By when i call it repeatedly it produce memory leakage and memory of my application
keeps on increasing constantly.


I am not able to understand what exactly wrong with this.
whether ReachtextEdit produce leak or Interop opration produce leak or any other reason .


any help would be appriciated.


Thanks
 
Using my amazing powers of ESP I am able to see your code in my head and I can see exactly where the problem is. Wait... the image is fading... I'm losing it... nope, it's gone. It's a shame that ESP is so unreliable. I guess you'll just have to post the code so that we can look at it in the conventional way.

The first thing you should do though, is to use your C# library in a C# app in a similar way and see what happens. If there's no memory leak then the issue would be in your C++ code, which seems the more likely anyway.
 
first of all thanks for the reply ..
ya definitely the code is here .
And I already tried this code in C-sharp application. It is working very fine there.
    public interface IRTF2TXTConverter
    {
         string Convert(string strRTFTxt);
        //int Add(int num1, int num2);
        
    };


    [Guid("C6659361-1625-4746-931C-36014B146679")]
    public class RTf2TXT : IRTF2TXTConverter
    {
        public string Convert(string strRTFTxt)
        {
            string path = strRTFTxt;


            //Create the RichTextBox. (Requires a reference to System.Windows.Forms.)
            System.Windows.Forms.RichTextBox rtBox = new System.Windows.Forms.RichTextBox();


            // Get the contents of the RTF file. When the contents of the file are   
            // stored in the string (rtfText), the contents are encoded as UTF-16.  
            string rtfText = System.IO.File.ReadAllText(path);


            // Display the RTF text. This should look like the contents of your file.
            //System.Windows.Forms.MessageBox.Show(rtfText);


            // Use the RichTextBox to convert the RTF code to plain text.
            rtBox.Rtf = rtfText;
            string plainText = rtBox.Text;


            rtBox.Clear();
            rtBox.Dispose();
            //System.Windows.Forms.MessageBox.Show(plainText);


            // Output the plain text to a file, encoded as UTF-8. 
            //System.IO.File.WriteAllText(@"output.txt", plainText);


            return plainText;
        }
    }
}
 
Last edited by a moderator:
I already tried this code in C-sharp application. It is working very fine there.

Then that suggests strongly that the issue is in the C++ code.
 
Back
Top Bottom