2

I'm using very big memory layers:

Is there any way to empty (fast), destroy or clean a layer in memory from an script without exit from this script ?

xunilk
  • 29,891
  • 4
  • 41
  • 80
Juanma Font
  • 823
  • 9
  • 13

2 Answers2

4

Have you tried

del(layer)

These should remove the reference to the layer and call the layer destructor.

A.A
  • 533
  • 5
  • 14
3

In your script you can use:

QgsMapLayerRegistry.instance().removeMapLayer(mem_layer.id())

assuming that the name of memory layer is 'mem_layer'.

xunilk
  • 29,891
  • 4
  • 41
  • 80
  • You have to add the layer to the registry in order to remove it (and delete it) in this case. If you are just working with arrays in memory then you want to delete the handle without adding it to the registry (saving time). – A.A Dec 08 '16 at 11:32