Size itself is not a problem. If you want to initialize one object for each request, you will write a lot more memory. The problem is access.
If you have a large number of queries competing for the same object, you need to measure the access time for this object or instantiation. Keep in mind that for data objects, more than one stream can read them. My understanding, however, is that when calling an object's function, it blocks that object for other threads until the function returns.
In addition, if the object maintains state, you need to think about what to do when multiple threads receive / set this data. Are you done with the race conditions?
You can consider accessing this object in the session area so that it is created only for each user (who is likely to make only one or two simultaneous requests).
Ben doom
source share