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

Providers occupy too much memory #968

neumond opened this issue Nov 12, 2020 · 1 comment

Providers occupy too much memory #968

neumond opened this issue Nov 12, 2020 · 1 comment
enhancement Enhancement proposals


Copy link

neumond commented Nov 12, 2020

Bug report

What's wrong

Open a REPL, create not-so-huge amount of providers:

>>> a = [mimesis.Business() for _ in range(10000)]

Not examine memory footprint of the process: in my case it's 1,1g.

How is that should be

Why would I need so many providers? I never knew they're such heavy objects, I was using them naively in tests:

def user_factory():
  mgen = mimesis.Person()
  async def user_factory():
    name =
  return user_factory

Seems like pytest keeps references to each fixture value, even if the test has finished. In our case it's closure with mimesis provider. For each test we create a provider or several of them. This leads to huge memory consumption of test suite.

I agree that correct use would be

def mimesis_person_gen():
  return mimesis.Person()

def user_factory(mimesis_person_gen):

this fixes memory consumption issue. But there's no any mention in documentation that provider objects are that heavy and one should construct them as few as possible. Probably issuing a warning on constructing 1000th provider would help many people who try to find out why their tests consume so much memory.

@lk-geimfari lk-geimfari added the enhancement Enhancement proposals label Nov 13, 2020
Copy link

I agree. I'll add much more information about memory usage.

lk-geimfari added a commit that referenced this issue Nov 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
enhancement Enhancement proposals
None yet

No branches or pull requests

2 participants