473,788 Members | 2,848 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

RAM used goes crazy with Dllimport ?

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(dlle xport) int main(int argc, char** argv) {

2)

[DllImport("xmat hs.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 ?
Nov 17 '05 #1
1 1725
Error found

Fixed C# code:
[DllImport("pac. dll", CallingConventi on=CallingConve ntion.Cdecl)]

public static extern int main(int argc, string[] argv);
string[] be = { "CHunter.ex e", "-1", "Test.paq", "Test.txt" };
int handler = Class1.main(be. Length -1, be);
---

"Brian Anderson" <no****@127.0.0 .1> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
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(dlle xport) int main(int argc, char** argv) {

2)

[DllImport("xmat hs.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 ?

Nov 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
4469
by: Jim | last post by:
I am extremely frustrated. I am building c# application for a call center and am using a third party API to access some hardware. When develop and test my class using the windows console the application runs flawlessly, but once I call the class from inside a c# windows application the program freezes, crashes etc... there must be a way to make this work inside a windows app as it run great as a command line app.
9
4975
by: Ole Christensen | last post by:
I'm trying to make a sort of conditional compilation in my C# code because my app is intended to run on both a Pocket PC and on a normal desktop PC. My code uses a call to an API function that on the PPC is located in coredll.dll and on the desktop in kernel32.dll. I could make two versions of the DllImported funktions but then I would have to ask for the OS version in every call to the function. This however causes the code to look messy...
3
3460
by: Mark Jerde | last post by:
I'm sill learning VS .NET 2003, not an expert yet. I'm calling an unmanaged C++ DLL from C# using . When the whole project is done I will be calling a total of 5 C++ DLLs from C#. All the DLLs have the same signature, and I never have to call more than one DLL in the same program. (The DLLs parse and validate 5 different binary formats.) Originally I was expecting to have 5 different C# programs as the constants are different for each...
2
1580
by: Benny Raymond | last post by:
Hi, I'm working on an app that has to inherit Form and override WndProc for several different reasons. Anyway it performs some actions on the window when WM_CREATE is called. The big problem right now is that the designer view goes nutz when it opens up because the program doesn't load the configuration correctly. Is there anything i can do to keep that block of code from running when in designer view? Perhaps something like this: #if...
2
10483
by: Brian Anderson | last post by:
Hello, is it possible to use DllImport to call a DLL in ASP.NET ? Or is it necessarry that my DLL has to be copied into \System32 ? My DLL is a native C++ 7.1 DLL (not managed, no COM, no regsvr32) and uses Assembler to make some math in SSE. The result is given out as an Int. Using a C# console app (code below) it work fine & fast.
2
1072
by: NetRacer | last post by:
hi, i've i little problem with a DataGrid bound with an AccessDB. is has 3 columns, the third formatted as currency. when i try to enter a new line, the (Null)-Strings appear in each column. if i change one column and want to enter the next one (by tab or mouse) it cleares my entry back to (Null). this happens with all columns. if i then enter another new row i can change the columns of the first one but with the new one again the...
0
1115
by: Linda Jimerson | last post by:
Hello - I created a simple Bulleted Rollover List from a Listamatic resource. When I contain this list (in a DIV with a width), IE 6.0 goes crazy (makes a mess). All other browsers act properly. I've loaded my html/css so you can see. Hope someone can help. Thanks so much. Linda at Across the Universe. http://www.acrosstheuniverse.net/bullletlist.htm
9
8214
by: jjones7947 | last post by:
Am doing a JNI wrap on a C++ API, am using VC7 and Eclipse. In preparation, I created a C++ executable which mimicked the flow of the JNI, i.e. a driver file which called methods in file with methods which call the API functions I want to use. That compiled and ran well. The C++ code is as follows: My header file void createSummarizer(char* rdir, char* lFile, char* key); void createInputOptions(const char* genre, const char* variant, const...
1
5801
by: elke | last post by:
Hi, I want to use an unmanaged dll in C# .net and I'm having some troubles witch a function that should return an array. I'm new at this, so I don't know what I'm doing wrong. Here is some code: #define USERINT_FUNC __cdecl #ifdef __cplusplus extern "C" { #endif
0
9498
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10364
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10110
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9967
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8993
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7517
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5398
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5536
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3670
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.