{
  "id": 18659990,
  "title": "A New JsonSerializerOptions Every Call Cost Me 120x",
  "url": "https://urgent.news/2026/11/07/a-new-jsonserializeroptions-every-call-cost-me-120x",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-11-07T07:14:09.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/ssukhpinder/a-new-jsonserializeroptions-every-call-cost-me-120x-299f"
  },
  "original_language": "en",
  "account": "A programmer noticed a significant slowdown in a list endpoint on their service, which they traced back to a new JsonSerializerOptions being created on every call. The JsonSerializerOptions object was thought to be a simple settings bag, but it turns out it builds metadata for serialization when first used and then caches it. Creating a new options object for each serialization call resulted in the serializer rebuilding its entire type model, leading to 120 times slower performance and 42 times more memory allocation compared to reusing a single cached instance. To optimize the code, the programmer moved the JsonSerializerOptions creation outside the method, building it once and reusing it for all serialization calls.",
  "summary": "A list endpoint on one of my services started showing up heavier in the traces than it had any right to be. It pulled a small object, serialized it, returned it. The payload was tiny — an order with three line items. But under load the thing allocated like it was streaming a video, and the CPU time didn't match the shape of the work. I went looking for the expensive query. There wasn't one. The…",
  "key_points": [
    "Creating a new JsonSerializerOptions object for each call caused performance slowdown.",
    "Reusing a single cached JsonSerializerOptions instance improved performance 120x.",
    "Moving JsonSerializerOptions creation outside the method optimized memory allocation 42x."
  ],
  "editors_take": "Treating configuration objects as disposable instead of reusable assets forces the serializer to rebuild its internal type model repeatedly, turning a simple settings bag into a massive performance bottleneck.",
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}