Hello,

I have written the same code in c# and i seem to have any problems?

I use 'procexp.exe' to check the performance.

In the case of 'c++' the VM (Virtual Memory) and PM (Physical Memory) becomes larger every minute.

There is also an I/O block with a lot of parameters :-)

In c# only the parameter 'other' gets larger, the other parameters stay the same.

In c++ all the parameters change?!

#include <iostream>
#include <string>

#import <c:\Atm\Dll\Payment.tlb> named_guids raw_interfaces_only


using namespace std;

int main()
{
	// Initialize
	CoInitialize(NULL);

	Payment::IPaymentAcsPtr pPaymentAcsPtr;

	HRESULT hres = pPaymentAcsPtr.CreateInstance(Payment::CLSID_PaymentAcs);


	// InitTerminal
	
		
	// Params

	
	FILE *hFile;
	int ret;
    hFile = fopen("C:\\atm\\logs\\transin.txt","w");

	ret = fprintf( hFile, "Amount to pay          : %i\n", 0);
	ret = fprintf(hFile, "Authorisation code EMV : %s\n", "");
	ret = fprintf(hFile, "Card Status            : %s\n", "1");
	ret = fprintf(hFile, "Card Type              : %s\n", "8");
	ret = fprintf(hFile, "Cashregister ID        : %s\n", "");
	ret = fprintf(hFile, "Command mode           : %s\n", "49152");
	ret = fprintf(hFile, "Currency Amount To Pay : %s\n", "1");
	ret = fprintf(hFile, "Inifile                : %s\n", "C:\\Atm\\Eft\\Eftcom.ini");
	ret = fprintf(hFile, "Operator ID            : %s\n", "");
	ret = fprintf(hFile, "Password               : %s\n", "");
	ret = fprintf(hFile, "Pin EMV                : %s\n", "");
	ret = fprintf(hFile, "Proton                 : %s\n", "1");
	ret = fprintf(hFile, "Reference              : %s\n", "");
	ret = fprintf(hFile, "Signature EMV          : %s\n", "");
	ret = fprintf(hFile, "Period TimeOut         : %i\n", 0);
	ret = fprintf(hFile, "Tip amount             : %i\n", 0);
	ret = fprintf(hFile, "Transaction ID         : %s\n", "");
	ret = fprintf(hFile, "Transaction Protocol   : %s\n", "");
	ret = fprintf(hFile, "IP Adress              : %s\n", "ping.banksys.be");
    fclose(hFile);

	

	pPaymentAcsPtr->InitTerminal();

	// Check Transuit.txt  

	// CheckCardBefore

	for (int i=1; i <= 50000; i = i +1)
	{
		pPaymentAcsPtr->CheckCardBefore();
		//Sleep(1000);
		cout << i << " ";
		
		
	}

	for (int i2=1; i2 <= 50000; i2 = i2 +1)
	{
		pPaymentAcsPtr->CheckCardBefore();
		//Sleep(1000);
		//cout << i2 << " ";
	}

	for (int i3=1; i3 <= 50000; i3 = i3 +1)
	{
		pPaymentAcsPtr->CheckCardBefore();
		//Sleep(1000);
		//cout << i3 << " ";
	}

Recommended Answers

All 2 Replies

>>In the case of 'c++' the VM (Virtual Memory) and PM (Physical Memory) becomes larger every minute.

Memory leak. Check your program for memory allocations that were not freed before a function ends. Quite possibly in pPaymentAcsPtr->CheckCardBefore() since your program is calling that function 150,000 times :icon_eek:

>>In the case of 'c++' the VM (Virtual Memory) and PM (Physical Memory) becomes larger every minute.

Memory leak. Check your program for memory allocations that were not freed before a function ends. Quite possibly in pPaymentAcsPtr->CheckCardBefore() since your program is calling that function 150,000 times :icon_eek:

I thought so too :-)

But if i run the same code in a c# program - the memory doesn't increase the same way.....

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.