private static ClusterResourceLimits calculateAndSetResourceLimits(ContentCluster contentCluster,
                                                                           DeployState deployState,
                                                                           ModelElement contentElement) {
            boolean isHosted = stateIsHosted(deployState);
            var resourceLimitMemory = deployState.featureFlags().resourceLimitMemory();
            if (isHosted) {
                double memoryGib = contentCluster.getSearch()
                                                 .getSearchNodes()
                                                 .stream()
                                                 .mapToDouble(s -> s.getHostResource().realResources().memoryGiB())
                                                 .min()
                                                 .orElse(16);
                // Use smaller limit for small nodes (when memory < ~8 Gib)
                if (memoryGib < 8.1)
                    resourceLimitMemory = 0.75;
            }

            var resourceLimits = new ClusterResourceLimits.Builder(isHosted,
                                                                   deployState.featureFlags().resourceLimitDisk(),
                                                                   resourceLimitMemory,
                                                                   deployState.featureFlags().resourceLimitLowWatermarkDifference(),
                                                                   deployState.getDeployLogger())
                    .build(contentElement);

            // Set resource limits both for nodes and for cluster
            contentCluster.search.getSearchNodes().forEach(node -> node.setResourceLimits(resourceLimits.getContentNodeLimits()));
            contentCluster.search.setResourceLimits(resourceLimits.getContentNodeLimits());

            return resourceLimits;
        }
The admin model of this system or null if none (which only happens in tests)
config-model/src/main/java/com/yahoo/vespa/model/content/cluster/ContentCluster.java