I'm looking into an issue I'm having with Raster and RasterLayer. I periodically load a new RasterLayer every couple seconds and remove an old RasterLayer. See code below.
Esri::ArcGISRuntime::Raster* raster = new Esri::ArcGISRuntime::Raster(QString::fromStdString(filename), raster_group_layer_);
Esri::ArcGISRuntime::RasterLayer* raster_layer = new Esri::ArcGISRuntime::RasterLayer(raster, raster_group_layer_);
QList<QColor> colors = ...
Esri::ArcGISRuntime::ColormapRenderer* colormap_renderer = new Esri::ArcGISRuntime::ColormapRenderer(colors, this);
raster_layer->setRenderer(colormap_renderer);
raster_layer->setLayerId(QString::fromStdString(guid.toString()));
Esri::ArcGISRuntime::Layer* old_layer = findLayer(raster_group_layer_->layers(), guid.toString());
raster_group_layer_->layers()->removeOne(old_layer);
raster_group_layer_->layers()->append(raster_layer);
The behavior I observe is leaked open file handles. When I call "lsof -p <pid>" on my process I see the same tif open repeatedly; this grows as time goes on. I am certain these open file handles are from the code above (I commented it out and the file list did not grow). The file handle list grows until eventually the process dies due to too many open files.
- What is the recommended way to delete a Raster and RasterLayer? I've tried:
delete raster_layer;
and
group_layer_->layers()->removeOne(raster_layer);
I suspect the latter is correct since it does appear to remove the image from display.
- Do you observe similar behavior with RasterLayer file handle leaks? Reproduction of this should be straightforward, let me know if it isn't and I can invest in a fully reproducible example.
Also some other questions related to my workflow. Basically I have some sensor raster data in memory I want to throw onto the map. It changes frequently.
- Is there a way to just hand in a QImage and transform to the RasterLayer directly? As a workaround I write a tiff to memdisk, then create a new RasterLayer on each update. As you may guess this is expensive and hacky.
- Is there a way to simply say, "reload the file" or "load this other new file" so I don't need to make a new RasterLayer each time?
Anyways thank you for looking at this, any suggestions are welcome!
Edit: confirmed happening on v100.9 and v100.11.