Bug report #6795

Possible Memory Leak in Map Rendering

Added by Brent Kowal over 11 years ago. Updated about 11 years ago.

Status:Closed
Priority:Severe/Regression
Assignee:-
Category:Map Canvas
Affected QGIS version:master Regression?:No
Operating System:All Easy fix?:No
Pull Request or Patch supplied:No Resolution:
Crashes QGIS or corrupts data:Yes Copied to github as #:15943

Description

There is a potential memory leak with the map canvas when rendering raster images. With a single raster loaded (TIF) each change to/update of the map canvas causes an increase in memory usage without it being cleared out. For this particular raster, about 1MB per refresh. QGIS Version: 1.9.0+git20121127+b9b943d~precise1

Potential valgrind output of the problem:
16099 6,010,724 (480 direct, 6,010,244 indirect) bytes in 10 blocks are definitely lost in loss record 17,982 of 17,984
16099 at 0x4C2B1C7: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
16099 by 0x7E17EAA: QgsRasterDataProvider::block(int, QgsRectangle const&, int, int) (in /usr/lib/libqgis_core.so.1.9.0)
16099 by 0x7E49F9E: QgsMultiBandColorRenderer::block(int, QgsRectangle const&, int, int) (in /usr/lib/libqgis_core.so.1.9.0)
16099 by 0x7E413BB: QgsRasterResampleFilter::block(int, QgsRectangle const&, int, int) (in /usr/lib/libqgis_core.so.1.9.0)
16099 by 0x7E21868: QgsRasterProjector::block(int, QgsRectangle const&, int, int) (in /usr/lib/libqgis_core.so.1.9.0)
16099 by 0x7E26620: QgsRasterIterator::readNextRasterPart(int, int&, int&, QgsRasterBlock**, int&, int&) (in /usr/lib/libqgis_core.so.1.9.0)
16099 by 0x7E3949C: QgsRasterDrawer::draw(QPainter*, QgsRasterViewPort*, QgsMapToPixel const*) (in /usr/lib/libqgis_core.so.1.9.0)
16099 by 0x7E27794: QgsRasterLayer::draw(QPainter*, QgsRasterViewPort*, QgsMapToPixel const*) (in /usr/lib/libqgis_core.so.1.9.0)
16099 by 0x7E30C3B: QgsRasterLayer::draw(QgsRenderContext&) (in /usr/lib/libqgis_core.so.1.9.0)
16099 by 0x7D11ECE: QgsMapRenderer::render(QPainter*, double*) (in /usr/lib/libqgis_core.so.1.9.0)
16099 by 0x82D8242: QgsMapCanvasMap::render() (in /usr/lib/libqgis_gui.so.1.9.0)
16099 by 0x82D30A3: QgsMapCanvas::refresh() (in /usr/lib/libqgis_gui.so.1.9.0)

fix-some-memory-leaks.patch Magnifier (2.62 KB) Minoru Akagi, 2013-04-22 03:00 AM

Associated revisions

Revision 13d35ac3
Added by Nathan Woodrow about 11 years ago

Merge pull request #548 from minorua/raster_memory_leaks

Fix some memory leaks Fix #6795

History

#1 Updated by Nathan Woodrow about 11 years ago

  • Priority changed from Normal to High
  • Operating System changed from Ubuntu 64-Bit to All
  • OS version deleted (12.04 LTS)

I can replicate this on Windows XP, 7, 8. It can be a real issue if you are using a large raster layer. The memory usage can grow very quickly and never comes down until QGIS crashes out.

#2 Updated by Giovanni Manghi about 11 years ago

  • Crashes QGIS or corrupts data changed from No to Yes

Would not be better to tag this "causes crash or corruption" tickets to be tagged as blockers and try to solve them before 2.0?

#3 Updated by Vincent Schut about 11 years ago

I just want to confirm this bug. I'm digitizing from a large set of tiff's, and have to restart qgis from time to time to avoid a crash. Needless to say that this is highly annoying... I'm not good enough at C++ to create a patch, but if there's anything I can do to help investigate/solve this, please let me know.
Btw I'm on linux, and use qgis from master (frequently updated, building locally).

#4 Updated by Mathieu Pellerin - nIRV about 11 years ago

Also seeing memory growth and ultimately crash on both win7 and linux running master builds.

#5 Updated by Nathan Woodrow about 11 years ago

  • Priority changed from High to Severe/Regression

#6 Updated by Minoru Akagi about 11 years ago

Attached is a patch. It might not be perfect but large memory leaks should be fixed.

#7 Updated by Matthias Kuhn about 11 years ago

I had a quick look at it. Looks proper at the first glance.
Can you make a pull request out of this?
It will be easier to review / merge for the people responsible for the raster functionality.

#8 Updated by Minoru Akagi about 11 years ago

Matthias Kuhn wrote:

Can you make a pull request out of this?

I've done it: https://github.com/qgis/Quantum-GIS/pull/548

#9 Updated by Nathan Woodrow about 11 years ago

  • Status changed from Open to Closed

Also available in: Atom PDF