Libraries: File Mapping without DLL - page 2

 

Alex, how do you free memory when a file is no longer needed?

I mean, so that I don't have to shovel megs and gigs of RAM, because there may be many files.

 
Does CloseHandle help?
 
sergeev:

CloseHandle helps?

CloseHandle is called inside Close(), but it does not release memory, and by reopening (without creating) you can get the saved information.

This means that RAM is occupied.

void CMemMapFile::Close()
  {
   if(m_hmem!=NULL) CloseHandle(m_hmem); m_path=""; m_hmem=NULL; m_size=0; m_pos=0; m_mode=-1; // close the handle
  }
 

I think it would be better to change the file size to 0 for guaranteed memory release.

There are Grows to increase the size, add Delete to kill the file by zeroing the allocated memory.

 

Thank you. Very necessary thing.

And, perhaps, an off-topic question: can File Mapping be adapted to use external genetics (say, a script running in the terminal) instead of the standard one when optimising?

 
joo:

Thank you. Very necessary thing.

And, perhaps, an off-topic question: can File Mapping be adapted to use external genetics (say, a script running in the terminal) instead of the standard one when optimising?


Unless it is semi-automatic, someone has to start the tester and stop it anyway (this is if you intend to use claud).

And without claude there is no point in using a tester.

 
Urain:

CloseHandle is called inside Close(), but it does not release memory, and by reopening (without creating) you can retrieve the saved information.

I think it stays there until someone rewrites it. I've had this happen. The writing application closes the handle and the reading application doesn't. But it can read the data. But after some operations in the Windows, the data in the file changes.

Which means the RAM is full.

I'm not sure.
 

joo:

File Mapping can probably be adapted to use external genetics (say, a script running in the terminal) instead of the standard one when optimising?

If you use files for storing intermediate data, then of course you can. The main thing is to reset data to disc at some reference points, because if something happens, the information will be irretrievably lost.
 
sergeev:

I think it stays there until someone rewrites it. I've had that happen. The writing application closes the handle and the reading application doesn't. But it can read the data. But after some operations in the Windows, the data in the file changes.

I'm not sure.
I guess we need to check it in a guaranteed way. But I don't know how.
 
Urain:

Unless it's a semi-automatic, someone has to start the tester and stop it anyway (this is if you intend to use a claud).

ZY and without a claud there is no point in using a tester without a claud.

Yes, there is a problem with claud....

Well, I meant that the user runs the script on the chart and then starts optimisation in the tester (the script starts "slipping" the necessary variables through File Mapping to the optimised Expert Advisor). And how, when, and under what conditions to stop optimisation is another question (for example, the Expert Advisor receives the "ready" flag and the Expert Advisor's stuffing stops working, so the tester will do the remaining runs in idle mode - so it will quickly run the remaining runs).

It goes like this.