English 中文(简体)
管理中的C#无管理的密码记忆
原标题:Free unmanaged c-code memory in managed C#

我有一个大型的密码图书馆,用来撰写其结果。 我将其数据通过浮动阵列归还给类似C++方案(以避免经常档案I/O):

float* mgrib(...)

This worked fine in c++ where I could "free" the memory. I managed to get the data into C# properly via:

IntPtr pointer = mgrib(...);
float[] result = new float[ size ];
Marshal.Copy( pointer, result, 0, size );
Marshal.FreeCoTaskMem( pointer );

这属于一个漏洞,因为许多领域必须从这一职能中撤出。 如果其面积少于256个,那么它就发挥了巨大作用。 如果它越发失控,就会毫无警告。 如果我通过该档案妥善管理另一个档案(共计256多件)。 我远离欧安会专家,但256人似乎不止是巧合。

我欣赏任何见解。 感谢。

问题回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

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 ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签