Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8554063
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T14:47:46+00:00 2026-06-11T14:47:46+00:00

I have created a regular dll where I have one method GetRecord to allocate

  • 0

I have created a regular dll where I have one method GetRecord to allocate memory for RecordInfo structure.

struct RecordInfo{
  // Some Data member
}

BOOL GetRecord(RecordInfo *& pRecordInfo)
{
   // Allocate RecordInfo, fill data and return as out paramter.
}

Now I access this dlls from MFC application and after finish my work. I release RecordInfo in client using delete.

delete pRecordInfo;

In release mode there is no problem, However in debug mode application shows assertion failure. Can some one explain reason behind this behaviour.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T14:47:47+00:00Added an answer on June 11, 2026 at 2:47 pm

    If you want to allocate memory in a DLL and free it in client code, you should make sure that both the DLL and the client are built with the same version of the compiler and same CRT “flavor” (e.g. both are debug builds, or both are release builds).

    This is of course highly constraining.

    As an alternative, to decouple things better, you can export from the DLL functions to both allocate and deallocate your data structures (in your particular case you could add and export a DeleteRecord function from your DLL, and call delete from inside this function body).

    I suggest you reading this interesting blog post on the Old New Thing blog, and note especially the beginning sentence (emphasis mine):

    It should be second nature to you that the code which allocates
    memory and the code which frees memory need to use the same allocator.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following the standard, regular post sample app. I created some posts
From the regular aspnet_Users table I have created two sub-tables with one to one
I have to create a regular expression for some path conversion. Example for path
I have created some JQuery that will expand a div 'popup' on hover and
In Rubular, I have created a regular expression: (Prerequisite|Recommended): (\w|-| )* It matches the
I have created a pkg for my regular simple commands. They are non-static, to
I have created some jQuery and put it in an ascx include. It works
I have created a GPS service which reads location updates on a regular interval.
I have created a method where I can search for string placeholders, this I
I have a native regular C++ Dll which I want to call from C#

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.