I am using vector in my code
std::vector<CEventLogInfo >
class CEventLogInfo
{
// date and time
unsigned short m_sMonth;
unsigned short m_sDay;
unsigned int m_nYear;
unsigned short m_sHour;
unsigned short m_sMin;
unsigned short m_sSec;
unsigned long m_nGatewayMacID;
unsigned char m_byCommandType;
unsigned char m_byStatus;
unsigned char m_byEventName;
unsigned char m_byDirection;
unsigned short m_nPacketLen;
char* m_pPacket;
// ..some method
}
CEventLogInfo::CEventLogInfo(const CEventLogInfo& refMessage)
{
m_sMonth = refMessage.m_sMonth;
m_sDay = refMessage.m_sDay;
m_nYear = refMessage.m_nYear;
m_sHour = refMessage.m_sHour;
m_sMin = refMessage.m_sMin;
m_sSec = refMessage.m_sSec;
m_nGatewayMacID = refMessage.m_nGatewayMacID;
m_byCommandType = refMessage.m_byCommandType;
m_byStatus = refMessage.m_byStatus;
m_byDirection = refMessage.m_byDirection;
m_byEventName = refMessage.m_byEventName;
m_nPacketLen = refMessage.m_nPacketLen;
if ( m_nPacketLen!=0)
{
m_pPacket = new char[m_nPacketLen];
memcpy(m_pPacket,refMessage.m_pPacket,m_nPacketLen);
}
else
m_pPacket = NULL;
}
void CEventLoggerBody::SetEventInfoList(EventInfoList& ListEventLog)
{
EventInfoList::iterator itrEventLogInfo;
for ( itrEventLogInfo = ListEventLog.begin(); itrEventLogInfo != ListEventLog.end();itrEventLogInfo++)
{
CEventLogInfo* pEventLogInfo = new CEventLogInfo(*itrEventLogInfo);
m_ListEventLog.push_back(*pEventLogInfo);
}
}
- here m_nPacketLen is variable but won't go beyond 22 bytes.
- this vector is working fine for 2000 record(44*2000)88000 bytes but when it goes beyond this it is crashing.I tested it for 5000 records it is crashing in the copy constructor when SetEventInfoList is called.
So the question is
- what is the maximum capacity of a vector that it can hold information in it.
- If vector doesn't support this much bytes then what STL container I should use for this.
Note:third party library is not allowed in my project,please suggest on pure c++ solution for this.