14

I am developing plugins and for some reason my QGIS keeps getting slower and slower. At first when I clicked on QGIS it opened right away, now it takes at least 2 minutes just to open and it also can take up to one minute just to close. Going into Manage and install plugins now times out because it takes forever to open. The way I'm pushing my changes is with this:

@echo off
SET OSGEO4W_ROOT=C:\OSGeo4W64
call "%OSGEO4W_ROOT%"\bin\o4w_env.bat

@echo off path %PATH%;%OSGEO4W_ROOT%\apps\qgis\bin path %PATH%;%OSGEO4W_ROOT%\apps\grass\grass78\lib path %PATH%;C:\OSGeo4W64\apps\Qt5\bin path %PATH%;C:\OSGeo4W64\apps\Python37\Scripts

set PYTHONPATH=%PYTHONPATH%;%OSGEO4W_ROOT%\apps\qgis\python set PYTHONHOME=%OSGEO4W_ROOT%\apps\Python37

set PATH=C:\Program Files\Git\bin;%PATH%

cmd.exe

Which is located in C:\OSGeo4W64. I then just type in pb_tool deploy in the directory of the plugin.

I tried reinstalling QGIS 3.10.7 but it didn't change anything. Also tried on QGIS 3.12 and 3.14 and it didn't change anything.

Looking for a way to fix my QGIS being so slow. My codes use a couple of files and they are quite large so I can't really post everything here, but I'm mostly using processing algorithms from qgis and grass and I use "memory:" and "TEMPORARY_OUTPUT" for QGIS and GRASS algorithms respectively.

Just tried the Plugin Load Times and it doesn't seem to be because of my plugins: enter image description here

Also here's the QGIS consumption when I just opened it and I have yet to even open a new project: enter image description here


The problem seems to be coming from my QGIS3.ini. When I create a new user it's size is only 13KB while the default one is 547,018KB. The new profile's QGIS3.ini looks like this: enter image description here

But the older one is actually insane it looks like this: enter image description here

The [UI] part contains hundreds of millions of characters by itself and I don't know why.

PolyGeo
  • 65,136
  • 29
  • 109
  • 338
EnGIsNowhere
  • 501
  • 1
  • 5
  • 12
  • 1
    I know nothing about what in a plugin makes QGIS slow but I have used the Plug-in load times plugin to see what is causing QGIS to open slowly. You might want to try it and see if your plugin is causing the slowdown. – Baswein Jul 13 '20 at 15:07
  • Did you remove your plugin(s) just to see how it impact the loading speed? – ThomasG77 Jul 13 '20 at 17:10
  • @ThomasG77 Yup I tried to uninstall them and it didn't change anything. My QGIS became slow all of a sudden and I can't find a way to get it as it was before. Just tried the Plugin Load Times like Baswein recommended and it takes only 4sec for all my plugins to load. – EnGIsNowhere Jul 13 '20 at 17:15
  • Did you look in the Windows Task Manager? Software can be slow just because others already consume most of the memory or CPU. – ThomasG77 Jul 13 '20 at 17:18
  • @ThomasG77 Yup I've looked it up and that's not the problem, however I edited my post because I forgot to mention my QGIS consumption in iddle looks absolutly crazy and I fear there's some kind of memory leak or something like that in one of the processing algorithms that I'm using. – EnGIsNowhere Jul 13 '20 at 17:26
  • What you're seeing in Task Manager is a feature introduced with Windows10(build 1809) if you have a GPU you should switch QGIS to use that. – Mapperz Jul 13 '20 at 17:47
  • 1
    What happened if you create a New Profile (e.g Settings -> User Profiles -> New Profile...) and run QGIS with it? Always slow? – ThomasG77 Jul 13 '20 at 17:54
  • @ThomasG77 OMG changing profiles opened a new QGIS instantly and my consumption is now 125MB instead of 1416Mb on iddle I've never done that what does creating a new profile change? I'm so happy right now my QGIS doesn't freeze when I zoom in on a raster :DDDDD – EnGIsNowhere Jul 13 '20 at 18:00
  • 1
    It's because "New Profile" more or less a QGIS with default conf, no plugins and other things (clearly do not know all about this) You can go to Settings -> User Profiles -> Open Active Profile Folder and do it for both your profiles and then can try to sort out why it's so slow by comparing contents from both folders. More a beginning to track the memory issue but at least a clue. – ThomasG77 Jul 13 '20 at 18:04
  • @ThomasG77 The only real difference I see between the 2 is that the QGIS3.ini for the default profile is 547,018KB while QGIS3.ini on the new profile is 13KB. Tried to open it in notepad++ my notepad crashed O_o – EnGIsNowhere Jul 13 '20 at 18:23
  • @ThomasG77 I was able to see length = 560 million in the default QGIS3.ini while the new one has length = 12,705 how the hell does that happen? – EnGIsNowhere Jul 13 '20 at 18:27
  • Try to use Winmerge to compare both files and folders. PS: not anymore on Windows, but was a good tool for the intent. – ThomasG77 Jul 13 '20 at 18:27
  • The init file contains all the history of expressions, of selections, recent loaded projects, db & webservices connection, SQL queries history, plugins conf,... That's why it's big – ThomasG77 Jul 13 '20 at 18:36
  • @ThomasG77 I've added in my post the difference between both files. The [UI] part of the QGIS3.ini is insanely large I feel like that souldn't be the case. Thanks for your help if I can't find a way to fix my old profile at least now I'll be able to work using a new one! – EnGIsNowhere Jul 13 '20 at 18:42
  • Comments are not for extended discussion; this conversation has been moved to chat. – Mapperz Jul 13 '20 at 20:22

2 Answers2

25

So after taking into account what ThomasG77 told me to fix my QGIS, I've found that indeed creating a new profile fixes the slowdown, but I didn't want to have to create a new profile everytime it got this slow, then reinstall my plugins,etc. The problem does seem to lie with the QGIS3.ini which kept getting bigger and bigger (After creating a new profile I saw that the default QGIS3.ini which I was using was 42000 times bigger than the one that you begin with from scratch).

However I found a simple solution to fix it without having to delete anything or create a new profile. You simply need to open QGIS, go in Settings > Options... > System. Then under "Settings" you'll see this: enter image description here

I tried it and this not only reset my QGIS3.ini from 547k KB to 59KB, but it also kept all of the plugins I'd installed. Now it opens super fast again and everything works as it should.

Alternatively, creating a new profile does work if you're scared that doing the reset will affect some changes you've made, but as for myself the reset accomplished everything I needed it to do.

EnGIsNowhere
  • 501
  • 1
  • 5
  • 12
  • 1
    This was a great find! It took my load times from 3 minutes (or more) to under 10 seconds. – Cary H Jun 10 '21 at 19:06
  • It would be interesting to see what in the qgis3.ini file that differs from the clean version. Trying a tool like https://text-compare.com/ with the raw text will show differences clearly. In my case the biggest difference was the "state=" settings. – Klas Karlsson Jul 07 '21 at 06:56
  • Any chance to use this Reset user interface function on PYQGIS? – Niels Janssens Sep 27 '21 at 14:50
16

More a guide than a definitive answer. It's a structured compilation of comments from the post.

Try to find out why it's slow by using

  • a plugin called "Plugin Load Times" to see plugins loading consumption. Be careful as stated in the plugin description

    It does not give you information about the speed of plugins when they are used.

  • try to disable all your plugins to track if any memory leak somewhere

  • see your overall memory consumption (using Windows Task Manager if Windows; use glances, top or ps on Linux; use OSX Task Manager for Mac)

  • try to create a new user profile and use QGIS with it going to "Settings -> User Profiles -> New Profile...". If it works, try to compare both Profile folders by opening both of them using "Settings -> User Profiles -> Open Active Profile Folder". Profiles are more or less like a reset, you need to reinstall plugins. They can be useful if you have different QGIS user profiles in your company. Some people do only drawing: hide to them most buttons not for edition. Some other does only need to consult, give them only buttons to browse, click informations and select features, ...

  • close "Browser panel" window as it may cause a scan of directories that consume a lot of memory and slow things down

  • be sure you do not have a 2nd hard drive remains info (https://gis.stackexchange.com/a/384356/638) or you do not load stuff from a shared network hard drive disk. Try by loading stuff from local hard drive to be sure it's not related

  • Go to menu "Settings" > "Options". In new Windows, go to tab "System" > "Settings" > "Reset user interface to default settings (restart required)" and restart QGIS (info from accepted answer from the current question)

  • Particular case: when related to particular projects layer, it may be slow because you do not set an index (for vector data). Go to "Layer properties" > tab "Source" > "Geometry" and click on "Create Spatial Index". It may not be possible to do so (greyed option) if index already exists or the layer uses a vector format not supporting indexing within QGIS

This answer can also help troubleshooting in particular if network issues https://gis.stackexchange.com/a/402625/638 or plugins issues (by looking at "Log Messages Panel")

ThomasG77
  • 30,725
  • 1
  • 53
  • 93