Memory Expansion Cost Profiler
Free to download on every platform. Comes pre-installed on BotFone, BotPad and BotFlip — with extra free apps included.
About this app
WHAT IT DOES
This tool profiles memory expansion costs and gas consumption patterns by analyzing transaction traces and memory operation data. It scans historical transaction data to measure the memory usage of function calls, quantifying the gas cost associated with memory expansion operations. The profiler identifies functions that allocate large memory regions, tracking memory usage in bytes and calculating the corresponding gas costs based on the EVM's memory expansion pricing model (quadratic cost for memory expansion beyond 32-byte words). Results are presented as a detailed report showing each function's memory usage, gas cost, and a status indicator (ok/warn/bad) based on configurable memory thresholds. This is essential for developers optimizing gas usage, auditors identifying memory-heavy functions, and teams reducing contract deployment and execution costs.
HOW TO USE
Connect your wallet (read-only, no transaction required) and select the target network. Enter the contract name and address, set the memory threshold (bytes) that triggers warnings, and set the lookback blocks for memory analysis. Click "profile memory costs" and the tool will verify the contract, fetch transaction traces and receipts, and analyze memory usage patterns. Results display a summary with total calls, average and maximum memory usage, detailed memory cards showing each function's memory usage, gas cost, and status, and a table of all profiled functions. Use the report to identify memory-heavy functions, optimize gas usage, and reduce transaction costs.
TECHNICAL MECHANISM
The analyzer uses ethers.js v5.7.2 to perform a multi-stage memory expansion analysis. First, it calls eth_getCode to verify the contract is deployed and uses block explorer APIs to fetch verification status and ABI. The tool then retrieves transaction data and traces using debug_traceTransaction (when available) and eth_getLogs across the specified block range. It analyzes each transaction's memory operations, extracting memory expansion sizes from trace data and calculating gas costs based on the EVM's memory expansion pricing: memory is allocated in 32-byte words, and the cost increases quadratically with the number of words allocated (cost = 3 * words + words^2 / 512). The tool maps memory usage to function signatures using the ABI, identifying which functions are responsible for large memory allocations. Each function is assigned a status: ok (memory below threshold), warn (memory between threshold and 2x threshold), or bad (memory exceeds 2x threshold). The profiler also computes summary statistics including average and maximum memory usage across all analyzed transactions. Results are compiled into a structured report with detailed memory usage data, gas cost estimates, and status indicators.
WHAT IT CANNOT SEE
This tool cannot profile memory expansion costs for contracts that are not verified or have opaque implementation details where memory operations cannot be attributed to specific functions. It is limited by the RPC provider's rate limits and availability of debug_traceTransaction, which may be restricted on some providers (e.g., rate-limited, disabled, or only available for archival nodes). It cannot capture memory usage for transactions that have not been executed or are pending. The analysis relies on the accuracy and completeness of transaction trace data and contract verification; incomplete traces or missing transaction data may produce incomplete profiles. It cannot analyze memory expansion patterns for contracts that use assembly or inline assembly where memory operations are not clearly distinguishable from the trace data. The tool is limited to the specific transactions and contract instances that are accessible via RPC. It cannot guarantee that profiling captures all possible memory expansion scenarios without exhaustive transaction analysis across a large number of transactions and input variations. The gas cost estimates are based on the standard EVM memory expansion formula and may not account for all gas costs associated with memory operations (e.g., storage operations, copying).
PLEASE NOTE
This is a read‑only analytics tool—it never submits transactions or modifies contract state. It is designed for EVM‑compatible chains and works best with verified contracts and providers that support debug_traceTransaction. The profiling results are for informational and optimization purposes only and should not be considered a comprehensive gas audit. Always verify memory usage patterns against actual contract behavior and test with various input sizes. The memory threshold is configurable and may need adjustment based on your specific contract's memory usage patterns and gas cost tolerance.