f3-factory / fatfree-core

Fat-Free Framework core library
GNU General Public License v3.0
207 stars 88 forks source link

Hive body is so large, remove it and reduce memory? #232

Closed cybrobin closed 6 years ago

cybrobin commented 7 years ago

Hive contains a large number of array data, most of the data will not be used in many cases, and then assembled into the hive caused by the occupation of memory.

ikkez commented 7 years ago

Please be more specific.. you mean the hive['BODY'] variable? that is only populated when you send a request body, typically used when uploading a file via PUT i.e. If that is your concern, set the RAW variable to TRUE and it'll stop moving the input stream into the BODY variable.

cybrobin commented 7 years ago

sorry, I am afraid that I didn't make myself understood. All variable of hive. Hive contains a large number of array data, most of the data will not be used in many cases, and then assembled into the hive caused by the occupation of memory.

Rayne commented 7 years ago

The hive contains references to the GET|POST|COOKIE|REQUEST|SESSION|FILES|SERVER|ENV globals, configuration, state (e.g. routing and localisation) and optional user data defined by the developer.

(When working with one of the template systems it will copy and escape (if not disabled) the data to a clean local context. If you want to avoid copying data that isn't required by the templates you could provide custom hives.)

Do you have ideas for shrinking the hive without loosing configuration options or features? What would you like to remove?

ikkez commented 6 years ago

The HIVE contains important path, environment, diagnostic and input information and some global settings that are used not only by the base framework, but also for its own and 3rd party plugins. Nevertheless, the Hive is relatively small and performance-wise there are techniques to speed up template rendering, like @Rayne explained, but I would say that even that is negligible. I got a full webshop script that is taking less than 5MB memory most of the time.. what's wordpress' default memory consumption? around 30MB? So I don't see any issue here.