English 中文(简体)
使用我的DLL
原标题:Strange problems with new/delete in an app that uses my DLL

sorry for the cryptic question title. I m having a strange problem and i have no idea why it is happening. Fortunately, the code involved is pretty simple. But beofre we get to it, let me briefly describe my app. It is a multithreaded app that serves a large amount of data. Something like an in-ram database. It is possible to have multiple "databases" in it and load/unload them at runtime. Now the problem is with the memory deallocation. Please see the code bellow (names of classes etc are changed, but this should not matter):

void SS::AllocTree( double*** pba, int i, int d, int b, int split )
{
    this->m_tree = new my_tree( pba, i, d, b, split );
}

void SS::DeallocTree()
{
    delete this->m_tree;
    this->m_tree = NULL;
}

每次都打电话到<条码>代谢;m=,节目坠毁。 st:

     mydll.dll!_free_base(void * pBlock=0x0000000008496f70)  Line 109 + 0x14 bytes  C
    mydll.dll!_free_dbg_nolock(void * pUserData=0x0000000008496fa0, int nBlockUse=0x00000001)  Line 1428    C++
     mydll.dll!_free_dbg(void * pUserData=0x0000000008496fa0, int nBlockUse=0x00000001)  Line 1258 + 0xe bytes  C++
    mydll.dll!operator delete(void * pUserData=0x0000000008496fa0)  Line 54 + 0x12 bytes    C++
    mydll.dll!my_tree::`vector deleting destructor ()  + 0x94 bytes C++
    myprog.exe!SS::DeallocTree()  Line 57 + 0x34 bytes  C++
    myprog.exe!SSUnloader(void * arg=0x00000000084d6f80)  Line 1038 C++
    msvcr90d.dll!_callthreadstart()  Line 295   C
    msvcr90d.dll!_threadstart(void * ptd=0x00000000084dad30)  Line 277  C       

这里是树木分配的 trace迹:

     msvcr90d.dll!malloc(unsigned __int64 nSize=0x0000000000000058)  Line 56 + 0x21 bytes   C++
    msvcr90d.dll!operator new(unsigned __int64 size=0x0000000000000058)  Line 59 + 0xa bytes    C++
    myprog.exe!SS::AllocTree(double * * * pba=0x0000000008458ff0, int i=0x00000bde, int d=0x00000010, int b=0x00000008, int split=0x00000001)  Line 52 + 0xa bytes  C++
    myprog.exe!SSLoader(void * arg=0x000000000843cf80)  Line 932    C++
    msvcr90d.dll!_callthreadstart()  Line 295   C
    msvcr90d.dll!_threadstart(void * ptd=0x0000000008440d30)  Line 277  C

你可以看到,负荷/卸载是专为这项任务而单独建立的。 不使用任何原始物品,不使用任何习俗肥皂或任何东西,在我的奶粉或我的节目中,没有新的/替代习俗操作者。 我不知道为什么该方案要花在我的肩上,叫我删除,而是用新的文字,这不会发生。 如果我改动<代码>DeallocTree(),照此办理:

void SS::DeallocTree()
{
    ::operator delete( this->m_tree );
    this->m_tree = NULL;
}

之后,所有东西都做了罚款。 然而,这并不正确。 是否应当对操作者有类似之处? 如何确保这一问题不会在其他地方发生? 为了完成这项工作,我还要附上DeallocTree(以下简称“DeallocTree”)版本的痕迹:

    msvcr90d.dll!operator delete(void * pUserData=0x00000000086f5fa0)  Line 45 + 0xa bytes  C++
    myprog.exe!SS::DeallocTree()  Line 58   C++
    myprog.exe!SSUnloader(void * arg=0x0000000008735f80)  Line 1038 C++
    msvcr90d.dll!_callthreadstart()  Line 295   C
    msvcr90d.dll!_threadstart(void * ptd=0x0000000008739d30)  Line 277  C

谁能向我解释一下这里正在发生什么?

EDIT:
To clarify:
my.dll is loaded dynamically - VS 2008 output: myprog.exe : Loaded C:*Debugmydll.dll , Symbols loaded.
Note: i am correctly using debug version of the dll with debug version of my program and vice versa with release.
**my_tree is declared as:
my_tree* m_tree; // the tree

最佳回答

cl似乎就在 calls子里。 在“双轨”电话中,你注意到的是,它把各种功能直接删除,等等。 在分配中,分配工作由mvcr90d.dll执行。

您的旗帜是悬挂您国旗的国旗/MDd(或释放/MD),而右翼/MTd(或释放/MT)。 将它们交给/送交(或释放/释放)以及你的问题将消失...... 基本上,你会把电话拨打到复方车上,而不是试图用两种不同的方式打听。

问题回答

暂无回答




相关问题
Undefined reference

I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

typedef ing STL wstring

Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

Window iconification status via Xlib

Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?

热门标签