RAM used goes crazy with Dllimport ?

  • Thread starter Thread starter Brian Anderson
  • Start date Start date
B

Brian Anderson

Hello,

I have a native, C++ console app that uses ~26MB of RAM when it runs.
It uses quite a lot of RAM to make some math but will never xceed 26MB.

Now I've made a dll out of this code and use it with DllImport in a C#
console application.
Basically I just access main() and pass my parameters.

w00t! RAM used by the C# app is now 228 MB !
No matter if I use DllImport in ASP.NET or any .NET application, RAM use
goes evil.

1)
extern "C" __declspec(dllexport) int main(int argc, char** argv) {

2)

[DllImport("xmaths.dll")]
public static extern int main(int argc, string[] argv);

What is .NET doing here ? The DllImport works fine as I get the expected
result fom my Dll but it's impossible to use this on a production server.
The response time is fast, no 100% CPU use. Everything is fine but RAM
taken.

Is there a trick to tell C# to stop going wild ?
 
Error found

Fixed C# code:
[DllImport("pac.dll", CallingConvention=CallingConvention.Cdecl)]

public static extern int main(int argc, string[] argv);


string[] be = { "CHunter.exe", "-1", "Test.paq", "Test.txt" };
int handler = Class1.main(be.Length -1, be);
 
Back
Top