You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
classComment(EmbeddedDocument):
content=StringField()
classPost(Document):
title=StringField()
comments=EmbeddedDocumentListField(Comment)
ifPost.objects.count() ==0:
foriinrange(100):
Post(title=f"{i}", comments=[Comment[f"{i}"]]).save()
defok():
qs=Post.objectsforpostinqs:
post.titledefbug():
qs=Post.objectsforpostinqs:
post.commentsgc.collect()
ok()
print("collect after ok():", gc.collect()) # 0bug()
print("collect after bug():", gc.collect()) # collect many objects
gc.collect() does not collect anything after exiting ok(). However, it can collect some objects after exiting bug().
The more times Post.comments accessed, the more memory used.
Although this may not a big problem since it can eventually collect internally by python.
In my case, this increase several gigabytes of RAM within a few minutes.
The text was updated successfully, but these errors were encountered:
This is the minimal example I found:
gc.collect()
does not collect anything after exitingok()
. However, it can collect some objects after exitingbug()
.The more times
Post.comments
accessed, the more memory used.Although this may not a big problem since it can eventually collect internally by python.
In my case, this increase several gigabytes of RAM within a few minutes.
The text was updated successfully, but these errors were encountered: