Home > Software engineering >  About using the vector save large capacity array!
About using the vector save large capacity array!

Time:09-22

I read from the instrument on the measuring data, defines a vector class:
The inside of the class name, DataType, types are:
Long ptnumber;//the dot
Double X;//coordinates X
Double Y;//Y
Double Z;//Z coordinate
Cstrings Timestr;//measuring time

To define a vector class: vector & lt; DataType> VecStaDyn;


Instrument to measure a pushback to vecStaDyn once;
Now need long time to boot up instrument measurement
Tested both in the period of 3.5 million (3.45 million, 3.55 million) at a time stopped, instruments are still in the test, but the data is not updated, what reason be excuse me? The vector the maximum capacity of the problem? Warrior advice please!

CodePudding user response:

Suggest don't use the vector, use a list

CodePudding user response:

Can only be written to the file!

CodePudding user response:

Stack size since the childhood: global data stack of files or less or less or less hard disk array or less or less cloud storage or less
When the program needs to use such as around 2 gb to 1 TB storage, perhaps the simplest way is to use simulated memory file, speaking, reading and writing, speaking, reading and writing, Windows reference _fseeki64 function, Linux reference fseeko64 function,
 FILE * fA; FA=fopen (" A ", "rb +"); _fseeki64 (fA, 10000000000 i64 * sizeof (int), SEEK_SET); Fputc (fA, 0);//int A [10000000000]; 
Int B;
_fseeki64 (fA, 9999999999 i64 * sizeof (int), SEEK_SET); Fread (& amp; B, 1, sizeof (int), fA);//B=A, [9999999999].
_fseeki64 (fA, 9999999999 i64 * sizeof (int), SEEK_SET); Fwrite (& amp; B, 1, sizeof (int), fA);//A [9999999999]=B;
The fclose (fA);

CodePudding user response:

Every once in a while the data into a file, otherwise it is easy to out of memory

CodePudding user response:

The
refer to the original poster wudicainiao2 response:
I read data from the instrument, defines a vector class:
The inside of the class name, DataType, types are:
Long ptnumber;//the dot
Double X;//coordinates X
Double Y;//Y
Double Z;//Z coordinate
Cstrings Timestr;//measuring time

To define a vector class: vector & lt; DataType> VecStaDyn;


Instrument to measure a pushback to vecStaDyn once;
Now need long time to boot up instrument measurement
Tested both in the period of 3.5 million (3.45 million, 3.55 million) at a time stopped, instruments are still in the test, but the data is not updated, what reason be excuse me? The vector the maximum capacity of the problem? Warrior advice please!

Measure the size, the write file?

CodePudding user response:

Written documents to empty?

CodePudding user response:

Because the instrument measurement speed is faster, write file saved time will affect the ongoing measurement

CodePudding user response:

"Write files saved time will affect the ongoing"
Just write (does not contain OpenFile, CloseFile)

CodePudding user response:

Use another computer to save in the dual port RAM data saved to the SSD or ordinary hard disk,

CodePudding user response:

Use database, batch submission, so more memory

CodePudding user response:

references to the tenth floor chengbar response:
use database, makes little sense to batch submission, so more on memory

Anecdotal rumours have memory database,

CodePudding user response:

Tried several computers, all stop living in article 3543306 of the data, do not have any tips, it shows that with memory it doesn't matter?

CodePudding user response:

First reserve (10000) space, try the double thread,
A thread collection, buffering, remember; Another thread to read data, remember the location, reciprocating alternately,
As for can meet the requirements, only you learn after the test,

CodePudding user response:

reference 13 floor sichuanpb reply:
first reserve (10000) space, try the double thread,
A thread collection, buffering, remember; Another thread to read data, remember the location, reciprocating alternately,
As for can meet the requirements, only you learn after the test,

May refer to the following:
//loop to a function sends a length of 200 bytes (this is the fixed) buffer, 
//a function need to incoming buffer, the circulation of 240 bytes (fixed) new buffer for processing,
//when dealing with each new printing takes two bytes of the buffer
# ifdef _MSC_VER
# pragma warning (4996) disable:
# endif
#include
#include
#include
# ifdef _MSC_VER
#include
#include
#include
# define MYVOID void
# define vsnprintf _vsnprintf
# the else
#include
#include
#include
# define CRITICAL_SECTION pthread_mutex_t
# define MYVOID void *
# endif
//the Log {
# define MAXLOGSIZE 20000000
# define MAXLINSIZE 16000
#include
#include
#include
Char logfilename1 []="MyLog1. Log";
Char logfilename2 []="MyLog2. Log";
The static char logstr [MAXLINSIZE + 1];
Char datestr [16].
Char timestr [16].
Char MSS [4].
CRITICAL_SECTION cs_log;
The FILE * flog;
# ifdef _MSC_VER
The Lock (CRITICAL_SECTION void * l) {
The EnterCriticalSection (l);
}
Void Unlock (CRITICAL_SECTION * l) {
LeaveCriticalSection (l);
}
Void sleep_ms (int) ms {
Sleep (ms).
}
# the else
The Lock (CRITICAL_SECTION void * l) {
Pthread_mutex_lock (l);
}
Void Unlock (CRITICAL_SECTION * l) {
Pthread_mutex_unlock (l);
}
Void sleep_ms (int) ms {
Usleep (ms * 1000);
}
# endif
Void LogV (const char * pszFmt, va_list argp) {
* struct tm now;
Struct timeb TB;

If (NULL==pszFmt | | 0==pszFmt [0]) return;
Vsnprintf (logstr, MAXLINSIZE pszFmt, argp);
Ftime (& amp; TB);
Now=localtime (& amp; TB. Time);
Sprintf (datestr, "% d % % 4 d - 02-02 d", now - & gt; Tm_year + 1900, now - & gt; Tm_mon + 1, now - & gt; Tm_mday);
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related