Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / December 2004

Tip: Looking for answers? Try searching our database.

RAM used goes crazy with Dllimport ?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Brian Anderson - 26 Dec 2004 21:49 GMT
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 ?
Brian Anderson - 27 Dec 2004 01:28 GMT
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);

---

> Hello,
>
[quoted text clipped - 23 lines]
>
> Is there a trick to tell C# to stop going wild ?

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.