The Query service in Couchbase has several features to manage memory usage and prevent performance degradation due to excessive memory consumption. The per-request memory quota feature limits the maximum amount of document memory that a query request can use at any given time, while the node-wide document memory quota places a limit on the cumulative amount of document memory that active queries can use. These quotas can be configured at different levels (cluster, node, and request) and have default values or minimum/maximum limits to ensure practical usage. The Query service also has a soft memory limit that is adjusted based on system resources, and a garbage collector that runs periodically to reclaim memory. Additionally, there is a REST endpoint `/admin/gc` that can be invoked to run the garbage collector manually, which can help in reducing memory utilization but may cause high CPU usage.