{"record":{"id":"3ad95a405e6a1f2c","repo":"microsoft/garnet","slug":"store-log-memory-size-or-pagecount-must-be-specifi","errorCode":null,"errorMessage":"Store Log Memory size or PageCount must be specified","messagePattern":"Store Log Memory size or PageCount must be specified","errorType":"validation","errorClass":"TsavoriteException","httpStatus":null,"severity":"error","filePath":"libs/server/Servers/GarnetServerOptions.cs","lineNumber":712,"sourceCode":"                kvSettings.PageCount = PageCount;\n\n            logger?.LogInformation(\"[Store] Using page size of {PageSize}\", PrettySize(kvSettings.PageSize));\n            logger?.LogInformation(\"[Store] Each page can hold ~{PageSize} key-value pairs of objects\", kvSettings.PageSize / 24);\n\n            if (kvSettings.LogMemorySize > 0)\n            {\n                var pageCount = kvSettings.LogMemorySize / kvSettings.PageSize;\n                if (kvSettings.PageCount > pageCount)\n                    logger?.LogInformation(\"[Store] Warning: overriding specified PageCount of {kvSettingsPageCount} with smaller page count calculated from LogMemorySize limit divided by PageSize: {pageCount}\", kvSettings.PageCount, pageCount);\n\n                var bufferSize = NextPowerOf2(pageCount);\n                logger?.LogInformation(\"[Store] There are {LogPages} log pages in memory, of which {pageCount} are initially allocated\", PrettySize(bufferSize), pageCount);\n                logger?.LogInformation(\"[Store] Log memory size limit of {LogMemorySize} will be enforced\", PrettySize(kvSettings.LogMemorySize));\n            }\n            else\n            {\n                if (kvSettings.PageCount == 0)\n                    throw new TsavoriteException($\"Store Log Memory size or PageCount must be specified\");\n                var bufferSize = (int)NextPowerOf2(kvSettings.PageCount);\n                if (kvSettings.PageCount < bufferSize)\n                {\n                    logger?.LogInformation(\"[Store] Warning: overriding specified PageCount of {kvSettingsPageCount} with next power of 2 page count {bufferSize}\", kvSettings.PageCount, bufferSize);\n                    kvSettings.PageCount = bufferSize;\n                }\n                logger?.LogInformation(\"[Store] There are {LogPages} log pages in memory, all of which will be used because there is no MemorySize limit\", PrettySize(bufferSize));\n                logger?.LogInformation(\"[Store] No log memory size limit will be enforced\");\n            }\n\n            kvSettings.SegmentSize = 1L << SegmentSizeBits(isObj: false);\n            kvSettings.ObjectLogSegmentSize = 1L << SegmentSizeBits(isObj: true);\n            logger?.LogInformation(\"[Store] Using disk segment size of {SegmentSize}\", PrettySize(kvSettings.SegmentSize));\n\n            logger?.LogInformation(\"[Store] Using hash index size of {IndexMemorySize} ({indexCacheLines} cache lines)\", PrettySize(kvSettings.IndexSize), PrettySize(indexCacheLines));\n            logger?.LogInformation(\"[Store] Hash index size is optimized for up to ~{distinctKeys} distinct keys\", PrettySize(indexCacheLines * 4L));\n\n            AdjustedIndexMaxCacheLines = IndexMaxMemorySize == string.Empty ? 0 : IndexSizeCachelines(\"hash index max size\", IndexMaxMemorySize);","sourceCodeStart":694,"sourceCodeEnd":730,"githubUrl":"https://github.com/microsoft/garnet/blob/951b0fc6838721f89d102c2bbe1b914e8d39d700/libs/server/Servers/GarnetServerOptions.cs#L694-L730","documentation":"GetSettings requires the main store to have either a memory budget (LogMemorySize) or an explicit page count (PageCount). If LogMemorySize is 0/unset, the code enters the else-branch and demands kvSettings.PageCount != 0; when both are zero it throws TsavoriteException because Tsavorite cannot size an in-memory log without at least one of them.","triggerScenarios":"Starting the server with neither --memory (LogMemorySize) nor --pagecount (PageCount) specified for the store. Thrown at GarnetServerOptions.cs:711-712.","commonSituations":"A minimal/custom launcher that constructs GarnetServerOptions without setting MemorySize or PageCount; a config file that nulls out the default memory size; embedding Garnet via the API and forgetting to set KVSettings.LogMemorySize/PageCount.","solutions":["Specify a main-log memory budget, e.g. --memory 256m (LogMemorySize).","Or specify an explicit page count, e.g. --pagecount 512 (PageCount).","When embedding, set kvSettings.LogMemorySize or kvSettings.PageCount before initializing the store."],"exampleFix":"# before (fails: no memory or pagecount)\ngarnet-server\n\n# after\ngarnet-server --memory 256m\n# or\ngarnet-server --pagecount 512","handlingStrategy":"validation","validationCode":"// Ensure the store has a memory budget OR an explicit page count\nif (kvSettings.LogMemorySize <= 0 && kvSettings.PageCount == 0) {\n    throw new InvalidOperationException(\"Specify LogMemorySize or PageCount for the store.\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass --memory (or PageCount) in launch configs.","When embedding, set KVSettings.LogMemorySize or KVSettings.PageCount explicitly."],"tags":["garnet","config","tsavorite","storage","dotnet"],"backgroundTag":null,"analyzedSha":"951b0fc6838721f89d102c2bbe1b914e8d39d700","analyzedAt":"2026-08-13T19:01:32.939Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}