Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Breaking Memory Issue for Python background analyzer when using Search Paths with Python #7988

Open
vsfeedback opened this issue Aug 28, 2024 · 0 comments
Assignees

Comments

@vsfeedback
Copy link

This issue has been moved from a ticket on Developer Community.


[severity:It's more difficult to complete my work]
Visual Studio version: Visual Studio 2019 Professional (16.11.39)
Python version: Python 3.7

NOTE:
I apologize, I am unable to share my code, but it looks like the bug itself has more to do with the interaction of VS project 'Search Paths' and the 'Python background analyzer' than the code itself.

Description:
When using a Visual Studio project 'Search Paths' in a Python project, I have experienced significant slowness for all activities in Visual Studio and frequent crashes.
Occasionally a memory error indicating that my development machine has run out of memory occurs.
This appears to be caused by 'Python background analyzer' increasing memory consumption inappropriately.

Behavior:
Upon opening a Visual Studio solution and a path to 'Search Paths', 'Python background analyzer' can be seen (in task manager) to be consuming slightly more resources than normal.
When writing a python import statement, importing from the location in the project referenced in 'Search Path' we can watch the memory consumption for 'Python background analyzer' double.
Every time I write a new import statement from that resource, the consumption is multiplied
(205mb -> 410mb -> 615mb -> etc...).
It also increases memory when I run the website with 'python manage.py runserver'.
If I allowed 'Python background analyzer' to continue like this it would consistently cause lag and crashing in Visual Studio due to lack of available system memory.

It looks like Python background analyzer is duplicating the data that it collects from the 'Search Path' resource every time it has to analyze an import from that location.
I also noticed that once or twice, 'Python background analyzer' would not just multiply its consumption, but would steadily grow until memory ran out and Visual Studio crashed.

Example Project Structure:
TopLevel(dir)
-->.vs
-->WebsiteName.sln
-->WebsiteName(dir)
----->env(dir)
----->WebsiteName.pyproj
----->requirements.txt
----->WebsiteName(dir)
---------->DjangoApp(dir)
---------->DjangoApp(dir)
---------->DjangoApp(dir)
---------->WebsiteNameSetttings(dir)
---------->WebsiteNameSharedResources(dir)
---------->manage.py

Within this hypothetical example above, IntelliSense would be unable to recognize imports from the "WebsiteNameSharedResources" directory into a file in one of the "DjangoApp" directories.
 
Additional Context:
The project I have experienced this issue in is a Django website project with multiple pages and a slightly customized site structure.
IntelliSense is unable to recognize certain import resources even though they work at runtime and during unit testing. This results in an annoying 'unresolved import' underscore but causes no actual bugs.
In order to fix this, I added a path to 'Search Paths' that points to the location of the unrecognized resource.
This resolved the 'unresolved import' issue but caused the memory issue I am writing this about.

Impact and Temporary Fix:
When this bug is active, it makes development very difficult because of constantly increasing memory consumption, lag, and Visual Studio crashes. As a temporary fix, I have removed the 'Search Paths' reference to that resource. This means that I still have the 'unresolved import' underscore for that import with IntelliSense and do not have the ability to 'Go To Reference' but this is preferable to the memory bug.


Original Comments

Feedback Bot on 8/21/2024, 06:50 PM:

(private comment, text removed)


Original Solutions

(no solutions)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants