Select to view content in your preferred language

Possible memory leak with Dictionary Renderer and very dynamic attributes

101
0
yesterday
Labels (1)
imbachb
Regular Contributor

A while ago I've reported following issue

Solved: Possible memory leak with Dictionary Renderer and ... - Esri Community

for which a fix was released in ArcGIS SDK for Qt v200.8.2 and v.300.0.0.

> BUG-000181142: Memory leak with DictionaryRenderer and very dynamic attributes.

However, with both of these version we still experience the same issue.

Working set of the process is steadily increasing:

imbachb_3-1780659211689.png

Allocations do not seem to get deleted from the function `esri::cim_rule_engine::Style_parser::get_symbol_keys`

ArcGIS SDK v200.8.2

imbachb_2-1780658680854.png

ArcGIS SDK v300.0.0

imbachb_1-1780658660866.png

Is a cache of symbols being built? How large can we expect this cache to grow?

Please find attached a source code example. The example code does following:

  • Add a dictionary renderer using the app-6e stylx.
  • Add 200 graphics at random positions
  • Update attributes of all graphics on a timer

This function creates a timer which loops over all graphics and sets random attributes on each graphic, causing the leak.

namespace
{
const std::vector<std::string> identifications{"0", "1", "2", "3", "4", "5"};
std::uniform_int_distribution<std::size_t> identification_distribution{0, identifications.size() - 1};
const std::vector<std::string> mainIcons{
	"000000",
	"110000",
	"110100",
	"110101",
	"110102",
	"110103",
	"110104",
	"110105",
	"110107",
	"110116",
	"110200"};
std::uniform_int_distribution<std::size_t> mainIcon_distribution{0, mainIcons.size() - 1};
std::uniform_int_distribution<std::size_t> azimuth_distribution{0, 360};
const std::vector<std::string> modifiers{"00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10"};
std::uniform_int_distribution<std::size_t> modifiers_distribution{0, modifiers.size() - 1};

} // namespace

void
CustomDictionaryRenderer::drawSymbols()
{
	for (size_t i = 0; i < 200; i++) {
		auto geom = Point(8.5417, 47.3769, m_spatialReference);
		QVariantMap attributes;
		attributes["sidc"] = "1400010000110102000000";
		Graphic* graphic = new Graphic(geom, attributes, this);
		m_graphicsOverlay->graphics()->append(graphic);
	}

	QTimer* timer = new QTimer(this);
	connect(timer, &QTimer::timeout, this, [this] {
		for (auto graphic : *m_graphicsOverlay->graphics()) {
			QVariantMap attributes;
			auto identification = identifications[identification_distribution(m_generator)];
			auto mainIcon = mainIcons[mainIcon_distribution(m_generator)];
			auto sidc = "140" + identification + "010000" + mainIcon + "000000";
			attributes["sidc"] = QString::fromStdString(sidc);
			auto randomX = 8.5417 + (9.2417 - 8.5417) * static_cast<double>(rand()) / RAND_MAX;
			auto randomY = 47.3769 + (46.3769 - 47.3769) * static_cast<double>(rand()) / RAND_MAX;
			attributes["direction"] =
				QString::number(180.0 + (-180.0 - 180.0) * static_cast<double>(rand()) / RAND_MAX);
			attributes["speed"] = QString::number(10000.0 + (0.0 - 10000.0) * static_cast<double>(rand()) / RAND_MAX);
			attributes["staffcomment"] =
				QString::number(10000.0 + (0.0 - 10000.0) * static_cast<double>(rand()) / RAND_MAX);
			attributes["uniquedesignation"] =
				QString::number(10000.0 + (0.0 - 10000.0) * static_cast<double>(rand()) / RAND_MAX);
			attributes["additionalinformation"] =
				QString::number(10000.0 + (0.0 - 10000.0) * static_cast<double>(rand()) / RAND_MAX);
			auto point = Point(randomX, randomY, m_spatialReference);
			graphic->attributes()->setAttributesMap(attributes);
			graphic->setGeometry(point);
		}
	});
	timer->start(100);
}

We are using Windows 10, ArcGIS Maps SDK for Qt 200.8.2 / 300.0.0, and DirectX rendering API.

Addendum:
I let it run for a while, memory usage in the task manager increased from 100MB to 1.4GB. Now suddenly the map seems frozen. The symbols do not update anymore. I can not zoom or pan the map anymore. However it resumed when I switched the window into fullscreen mode and back ...

0 Kudos
0 Replies