Hi, @piyush.rajput , after analysis and testing, here is a brief report of the issue:
if you are running GroupDocs Conversion Cloud in a self-hosted container and notice that memory usage climbs after each conversion and never fully drops back, this is expected behavior — not a memory leak.
Why it happens
The .NET runtime manages its own memory heap. After a conversion completes, the runtime frees all managed objects internally but intentionally holds onto the OS memory pages for reuse on the next request. This avoids the overhead of repeatedly requesting memory from the OS. From Docker or Kubernetes’ perspective, the container’s RSS (resident memory) stays high even when the service is idle.
What to do
Set the DOTNET_GCConserveMemory environment variable. It tells the .NET garbage collector to actively return unused memory pages back to the operating system rather than holding onto them. The value is a scale from 0 (default, performance-optimized) to 9 (most aggressive memory trimming).
For document conversion workloads, a value of 9 is recommended:
env:
- name: DOTNET_GCConserveMemory
value: "9"
You can also set a hard ceiling on the GC heap to prevent the process from ever claiming more than a fixed amount. For example, to cap at 800 MB:
env:
- name: DOTNET_GCConserveMemory
value: "9"
- name: DOTNET_GCHeapHardLimit
value: "838860800"
Pair with a restart policy
Document conversion involves native libraries for font rendering and image processing. These allocate memory outside the .NET heap, which the GC cannot control. Over extended uptime under heavy load, this native memory can accumulate. The practical safeguard is a Kubernetes liveness probe combined with memory-based resource limits:
resources:
limits:
memory: "1Gi"
livenessProbe:
httpGet:
path: /
port: 80
initialDelaySeconds: 10
periodSeconds: 30
failureThreshold: 3
When the container exceeds its memory limit, Kubernetes will restart it automatically. Combined with DOTNET_GCConserveMemory, this keeps your pods lean during normal operation and recovers cleanly in edge cases.
Summary
| Setting |
Purpose |
DOTNET_GCConserveMemory=9 |
Return managed heap pages to OS aggressively |
DOTNET_GCHeapHardLimit |
Hard cap on .NET heap size |
resources.limits.memory |
Kubernetes-level safety net |
| Liveness probe |
Auto-restart on health failure |
For most self-hosted deployments, DOTNET_GCConserveMemory=9 alone produces a noticeable reduction in idle memory footprint with negligible impact on conversion throughput.