Skip to content

Memory leak with Django 1.7 and --create-db? #181

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

Closed
alvinchow86 opened this issue Oct 16, 2014 · 3 comments
Closed

Memory leak with Django 1.7 and --create-db? #181

alvinchow86 opened this issue Oct 16, 2014 · 3 comments

Comments

@alvinchow86
Copy link

Hey, I noticed some very strange memory usage issues lately. I'm using pytest-django 2.7 and Django 1.7, with Postgres 9.3 (+PostGis) as the database.

Basically if I run py-test on my test suite with --create-db (to create a new database), my Python process balloons to 700-800MB right off the bat (while the database is being created, and Django migrations are run), and stays at least that high (800MB+) throughout the test run. This is leading to out-of-memory issues on our integration server.

If I don't do --create-db and reuse the existing test database (--reuse-db), memory usage is normal (~150-200MB) throughout the test run.

When I was using Django 1.6 and pytest-django 2.6.2, there was no difference in memory between reusing and creating the test DB.

Any ideas? The main difference is that I'm using Django 1.7's migrations now (used to use South with Django 1.6, and --create-db just skipped South entirely).

@tdavis
Copy link

tdavis commented Dec 19, 2014

Yeah, definitely something fishy here. I haven't looked at the memory usage, but the duration says a lot: with --create-db my tests take 10 seconds; with reuse-db just one second. Squashing all my migrations had no effect, either.

@lisael
Copy link

lisael commented Feb 4, 2016

Same problem here. Seems like django migrate creates thousands of models and fields and never release them. In the standalone command it's not as bad, but testrunners use connection.create_db which in turn calls call_command('migrate') before running the tests in the same process, thus keeping the memory full. If someone has a solution, I'd gladly hear about it.

@blueyed
Copy link
Contributor

blueyed commented May 6, 2019

Not really a pytest-django issue it seems.

By now we have --no-migrations also, which currently still calls the migrate command, but with no-op migrations. With #729 it skips the migrate command altogether.

@blueyed blueyed closed this as completed May 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants