I am working on this high frequency production system. There is a C # / CLI layer that calls the C ++ library. We observe that managed objects go into Generation 2 of the garage collector and become stuck. In the end, C # applications stop when RAM ends. These managed entities are local entities and must have a very short lifespan. They are also mentioned only once. C # applications must call .Dispose () for all of their objects that contain their own resources so that everything is forcibly deleted. We have quite a few objects, so this is not ideal, but from the point of view of the API - randomly. The CLI is as follows:
Field::~Field() { if(m_pField != NULL) { delete m_pField; m_pField = NULL; } System::GC::SuppressFinalize(this); } Field::!Field() { if(m_pField != NULL) { delete m_pField; } }
Can anyone think why these short-lived objects never gather and free up memory?
source share