Documentation
Performance and Security/Resource Management

Resource Management

ThinkCode provides comprehensive tools and settings to monitor and control resource usage, ensuring optimal performance even on resource-constrained systems or with demanding workloads.

Resource Usage Overview

ThinkCode utilizes various system resources:

  • CPU: For code analysis, UI rendering, and AI processing
  • Memory: For storing workspace data, caches, and AI models
  • Disk: For workspace files, extensions, and temporary data
  • Network: For syncing, extension marketplace, and cloud AI services
  • GPU: For UI acceleration and some AI processing tasks

Understanding how ThinkCode uses these resources helps you optimize their allocation.

Resource Monitoring

Built-in Resource Monitors

ThinkCode includes several tools to monitor resource usage:

  1. Process Explorer

    • Open the Command Palette
    • Type "Developer: Open Process Explorer"
    • View CPU, memory, and GPU usage for each ThinkCode process
  2. Status Bar Indicators

    • Enable resource indicators in the status bar:
    {
      "thinkcode.resourceUsage.showInStatusBar": true,
      "thinkcode.resourceUsage.statusBarItems": ["cpu", "memory", "gpu"]
    }
  3. Detailed Resource Report

    • Generate a comprehensive resource usage report:
    • Open the Command Palette
    • Type "Developer: Show Resource Usage Report"

Performance Logging

Enable advanced resource monitoring through logging:

{
  "thinkcode.meeloper.resourceLogging": {
    "enabled": true,
    "detail": "verbose", // Options: "basic", "normal", "verbose"
    "frequency": 10000, // Logging interval in milliseconds
    "fileOutput": true // Write logs to disk
  }
}

Access logs via Help → Open Logs Folder → select "resource-usage" log.

CPU Management

CPU Priority and Throttling

Configure how ThinkCode utilizes CPU resources:

{
  "thinkcode.resources.cpu": {
    "priority": "normal", // Options: "low", "normal", "high"
    "maxUsage": 70, // Maximum CPU percentage to use
    "backgroundThrottling": true, // Reduce CPU usage when in background
    "throttleExtensions": true // Limit extension CPU usage
  }
}

Process-Specific Controls

Fine-tune CPU allocation for specific ThinkCode processes:

{
  "thinkcode.resources.processes": {
    "main": {
      "cpuPriority": "high",
      "cpuLimit": 0 // 0 means no limit
    },
    "renderer": {
      "cpuPriority": "normal",
      "cpuLimit": 60
    },
    "extensionHost": {
      "cpuPriority": "low",
      "cpuLimit": 30
    },
    "aiService": {
      "cpuPriority": "normal",
      "cpuLimit": 70
    }
  }
}

Thread Pool Configuration

Configure thread pools for parallel operations:

{
  "thinkcode.resources.threading": {
    "workerThreads": "auto", // "auto" or specific number
    "maxWorkers": 4, // Maximum worker threads
    "workStealingEnabled": true // Enable work stealing for better distribution
  }
}

Memory Management

Memory Limits

Set overall memory limits for ThinkCode:

{
  "thinkcode.resources.memory": {
    "maxHeapSize": 4096, // Maximum heap size in MB
    "initialHeapSize": 1024, // Initial heap size in MB
    "garbageCollection": "balanced", // Options: "conservative", "balanced", "aggressive"
    "swapUsage": "minimal" // Options: "none", "minimal", "normal"
  }
}

Memory Allocation

Control memory allocation for specific features:

{
  "thinkcode.resources.memoryAllocation": {
    "editor": 30, // Percentage of available memory
    "extensions": 20, 
    "ai": 30,
    "languageServices": 10,
    "other": 10
  }
}

Cache Management

Configure memory caches to balance performance and resource usage:

{
  "thinkcode.resources.caching": {
    "fileContentCache": {
      "enabled": true,
      "maxSizeMB": 200,
      "maxItems": 1000,
      "ttlSeconds": 1800 // Time to live
    },
    "symbolCache": {
      "enabled": true,
      "maxSizeMB": 100,
      "persistAcrossRestarts": true
    },
    "aiCache": {
      "enabled": true,
      "maxSizeMB": 512,
      "ttlSeconds": 604800 // 7 days
    }
  }
}

Memory Leak Detection

Enable memory leak detection during development:

{
  "thinkcode.meeloper.memoryMonitoring": {
    "leakDetection": true,
    "leakReporting": "immediate", // Options: "immediate", "shutdown", "both"
    "heapSnapshotOnLeak": false // Create heap snapshot when leak detected
  }
}

Disk Resource Management

Storage Allocation

Control how ThinkCode uses disk space:

{
  "thinkcode.resources.disk": {
    "tempDirSizeLimit": 1024, // Max temp dir size in MB
    "logFileRotation": {
      "maxFileSizeMB": 10,
      "maxFiles": 10
    },
    "workspaceCache": {
      "maxSizeGB": 2,
      "cleanupThresholdPercent": 80 // Cleanup when threshold reached
    }
  }
}

Cleanup Utilities

ThinkCode provides utilities to clean up disk usage:

  1. Automatic Cleanup:

    {
      "thinkcode.resources.diskCleanup": {
        "schedule": "daily", // Options: "never", "startup", "daily", "weekly"
        "cleanTempFiles": true,
        "cleanLogFiles": true,
        "cleanBackups": true,
        "cleanOldExtensions": true
      }
    }
  2. Manual Cleanup:

    • Open Command Palette
    • Type "ThinkCode: Clean Up Resources"
    • Select which resources to clean

Network Resource Management

Bandwidth Management

Configure network usage limits:

{
  "thinkcode.resources.network": {
    "maxBandwidth": 0, // 0 for unlimited, or specify in Kbps
    "backgroundUsage": "throttled", // Options: "normal", "throttled", "minimal", "none"
    "prioritizeActiveOperations": true // Prioritize foreground operations
  }
}

Connection Management

Control connections and timeouts:

{
  "thinkcode.resources.connections": {
    "maxConcurrent": 20, // Maximum concurrent connections
    "connectionTimeout": 30000, // Timeout in milliseconds
    "retryStrategy": {
      "initialDelayMs": 1000,
      "maxDelayMs": 10000,
      "maxRetries": 3
    }
  }
}

Offline Mode Configuration

Configure how network resources are managed in offline mode:

{
  "thinkcode.resources.offlineMode": {
    "autoDetect": true, // Detect offline status automatically
    "cacheStrategy": "aggressive", // Options: "minimal", "normal", "aggressive"
    "backgroundSyncEnabled": true, // Sync when connection restored
    "queueOperations": true // Queue operations for when online
  }
}

GPU Resource Management

GPU Acceleration

Configure GPU usage for supported features:

{
  "thinkcode.resources.gpu": {
    "enabled": true,
    "preferredDevice": "auto", // "auto" or specific GPU index
    "usageLevel": "balanced", // Options: "minimal", "balanced", "maximum"
    "features": {
      "rendering": true,
      "aiInference": true,
      "imageProcessing": true
    }
  }
}

WebGL Configuration

Adjust WebGL settings for UI rendering:

{
  "thinkcode.resources.webgl": {
    "enabled": true,
    "angleBackend": "default", // Options: "default", "gl", "d3d11", "d3d9", "metal"
    "powerPreference": "high-performance" // Options: "default", "high-performance", "low-power"
  }
}

Resource Profiles

ThinkCode allows you to create resource profiles for different scenarios:

Built-in Profiles

Choose from predefined resource profiles:

{
  "thinkcode.resources.activeProfile": "balanced" // Options: "minimal", "balanced", "performance", "custom"
}

Profile Characteristics

ProfileCPU UsageMemory UsageDisk CacheNetworkFeatures
minimalLimitedLowMinimalConservativeCore only
balancedModerateModerateModerateStandardMost enabled
performanceMaximumHighExtensiveAggressiveAll enabled
customUser definedUser definedUser definedUser definedUser selected

Custom Profiles

Create your own resource profiles:

{
  "thinkcode.resources.profiles": {
    "laptop": {
      "cpu": {
        "maxUsage": 50,
        "backgroundThrottling": true
      },
      "memory": {
        "maxHeapSize": 2048
      },
      "features": {
        "heavyFeatures": false
      }
    },
    "workstation": {
      "cpu": {
        "maxUsage": 90,
        "backgroundThrottling": false
      },
      "memory": {
        "maxHeapSize": 8192
      },
      "features": {
        "heavyFeatures": true
      }
    }
  },
  "thinkcode.resources.activeCustomProfile": "laptop" // Use a custom profile
}

Profile Switching

Switch profiles automatically based on conditions:

{
  "thinkcode.resources.automaticProfileSwitching": {
    "enabled": true,
    "conditions": {
      "onBattery": "minimal",
      "onExternalPower": "balanced",
      "onHighCpuLoad": "minimal",
      "onLowMemory": "minimal",
      "onHighPerformanceGpu": "performance"
    }
  }
}

Resource Reservation

Reserve resources for critical operations:

{
  "thinkcode.resources.reservation": {
    "enabled": true,
    "cpu": {
      "editorResponsiveness": 20, // Percentage reserved for editor
      "minFree": 10 // Minimum free percentage
    },
    "memory": {
      "criticalOperations": 512, // MB reserved for critical operations
      "minFreePercentage": 15 // Minimum free percentage
    }
  }
}

Resource-Aware Features

ThinkCode includes features that adapt to available resources:

Dynamic Feature Adjustment

Configure how features adapt to resource constraints:

{
  "thinkcode.resources.dynamicFeatures": {
    "enabled": true,
    "lowResourceMode": {
      "thresholds": {
        "cpuUsage": 90, // Percentage
        "memoryUsage": 85, // Percentage
        "diskSpace": 10 // Percentage free
      },
      "actions": {
        "disableHeavyExtensions": true,
        "reduceSyntaxHighlighting": true,
        "simplifyUI": true,
        "pauseBackgroundTasks": true
      }
    }
  }
}

Workspace Size Adaptation

Adapt to workspace size automatically:

{
  "thinkcode.resources.workspaceAdaptation": {
    "enabled": true,
    "largeWorkspaceThresholdMB": 500,
    "hugeWorkspaceThresholdMB": 2000,
    "adaptations": {
      "large": {
        "fileWatchers": "limited",
        "fullTextSearch": "optimized",
        "codeAnalysis": "basic"
      },
      "huge": {
        "fileWatchers": "minimal",
        "fullTextSearch": "manual",
        "codeAnalysis": "onDemand"
      }
    }
  }
}

Resource Optimization Tips

General Optimization

  1. Close Unused Editors: Limit the number of open editors
  2. Use Split Workspaces: Divide large projects into multiple workspaces
  3. Regular Restarts: Restart ThinkCode periodically on long sessions
  4. Update Extensions: Keep extensions updated for performance improvements
  5. Monitor Resource Usage: Regularly check resource monitors

System-Specific Optimization

Windows

  • Enable hardware acceleration
  • Run ThinkCode with admin rights for resource allocation
  • Use process priority settings in Windows

macOS

  • Check Activity Monitor for resource usage
  • Consider using App Nap disabling utilities
  • Monitor memory pressure in Activity Monitor

Linux

  • Use nice and ionice for process priority
  • Monitor resources with htop or glances
  • Configure appropriate swap space

Enterprise Resource Management

For enterprise administrators:

Centralized Resource Policies

Define resource policies for team members:

{
  "thinkcode.enterprise.resources": {
    "enforcePolicies": true,
    "policySource": "https://company-policies.example.com/thinkcode-resources.json",
    "allowUserOverrides": false,
    "resourceReporting": {
      "enabled": true,
      "reportingEndpoint": "https://metrics.example.com/thinkcode",
      "reportingInterval": 3600 // seconds
    }
  }
}

Remote Development Resources

Configure resource management for remote development:

{
  "thinkcode.remote.resources": {
    "localAllocation": {
      "cpu": "minimal",
      "memory": "moderate"
    },
    "remoteAllocation": {
      "cpu": "maximum",
      "memory": "maximum"
    },
    "syncStrategy": "delta", // Options: "full", "delta", "smart"
    "optimizeForNetworkType": "auto" // Options: "auto", "fast", "slow"
  }
}

Troubleshooting Resource Issues

Common Resource Problems

ProblemPossible CausesSolutions
High CPU UsageComplex code analysis, inefficient extensionsIdentify high CPU processes, disable problematic extensions
Memory LeaksExtensions with memory leaks, large workspaceRestart ThinkCode, update extensions, use memory profiling
Disk Space ConsumptionLarge workspace caches, log filesRun cleanup utility, configure smaller cache limits
Slow Network OperationsBandwidth limits, many concurrent operationsCheck network settings, limit concurrent operations
GPU-Related IssuesDriver problems, excessive renderingUpdate GPU drivers, disable GPU acceleration if problematic

Resource Diagnostics

Run resource diagnostics:

  1. Open Command Palette
  2. Type "ThinkCode: Run Resource Diagnostics"
  3. Review the diagnostic report
  4. Apply recommended actions

Reset Resource Settings

If you encounter persistent resource issues:

  1. Open Command Palette
  2. Type "ThinkCode: Reset Resource Settings"
  3. Select which settings to reset

Further Resources