Memory growth fast when schema is defined in a function
See original GitHub issueWhen I use the following code, I observe that memory growth is very fast, but when I define the schema outside the function, there is no problem.
def test_schema():
class FooSchema(Schema):
foo = fields.String()
# not do anything
return "xxx"
if __name__ == '__main__':
while True:
print test_schema()```
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Schemas and Memory - Psychologist World
Schemas and Memory. Schemas (or schemata) refer to a type of cognitive heuristic which facilitates our understanding of our environment.
Read more >Memory Schema - an overview | ScienceDirect Topics
Here, schema memory processing refers to the processes of integrating newly ... emphasis on functions of inner psychic structures and subjective meaning ......
Read more >Schema in Psychology: Definition, Types, Examples
In Piaget's theory, a schema is both the category of knowledge as well as the process of acquiring that knowledge.
Read more >The Role of a Schema in Psychology
A schema is a knowledge structure that allows organisms to interpret and understand the world around them. Schemata are a method of organizing ......
Read more >What Is a Schema in Psychology? Definition and Examples
A schema is a mental structure that helps organize knowledge into categories and understand and interpret new information.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hey @justanr, thanks for the reasoning and details explanation here which I appreciate. I too have hit this issue which causes high memory issues in my production environment. Now that I am aware of it I would like to know the suggested solution, in what I see as a valid use case here.
I typically use inheritance to generate classes to give standard packaging.
This way I can easily standardize my response formats across my schemas.
UserResponse.load_paged_result(response.content)
Is there a suggested solution here. I was thinking about manually checking things in spots, but I fear its hard to train others users to follow suit and avoid the memory leaks.
@jtillman You can prevent marshmallow from storing your generated classes in its internal registry of schemas by generating the classes without a name.
I’ve also proposed #660 , which would expose a more straightforward way to bypass the registry. In the meantime, the above workaround should get you most of the way.