A Delete question about the object pointer of the DLL export class

Source: Internet
Author: User
Tags export class

In addition to the analysis of video streams, I encountered a major problem this afternoon: The delete operation failed to export class-defined object pointers from DLL, memory leaks and memory leaks are the most common problems I 've encountered in the past few months. After getting used to Java and C #, I suddenly started to use C ++, and the memory would make you speechless. I finally couldn't find the problem, but I had to find a solution. I gave it a question: finally, we decided to add two global functions in the DLL and then export the two global functions, the same as calling the two functions in the called Project. One function returns an object pointer, And the other function releases the pointer. Needless to say, this method is done, but I still don't know why delete fails in the call project. Continue to observe...

On the weekend, I re-wrote a small program for testing. It seems that there was no memory leakage and it was very depressing...

First, record my solutions at that time:

Two global functions are added to the DLL typing class:

For example:

Void createinstanceptr (void **, void * Arglist );

Void freeinstanceptr (void **);

Someone may ask why void is used **. This is mainly for the passed pointer to a new object, so the pointer must be used. Well, write it here. The root problem is indeed not found. You still need to observe it with patience.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.