How can I record the highest memory using processes on my Windows box over time?

Use this batch file to record processes and their memory consumption to assist in detecting memory leaks on Windows.

@echo off

REM schedule this to run in your task scheduler as frequently as you need it (say every 15 minutes)
REM do not run from ProTop's scheduler as this script does not work with the sort command provided with ProTop
reM This is just an example, your milage may vary.

set LOGDIR=c:\protop\log

set logfile=%LOGDIR%\mem_usage.log

echo. >> %logfile%
echo Logging process memory usage at %date% %time% >> %logfile%
echo ============================================================================== >> %logfile%
echo. >> %logfile%
echo Process List (Top 10 sorted by Memory Usage in KB, descending): >> %logfile%
echo. >> %logfile%
echo Image Name PID Session Name Session# Mem Usage >> %logfile%
echo ========================= ======== ================ =========== ============ >> %logfile%

:: Capture the list of all processes with PID and memory usage, sort by memory usage in descending order

tasklist /fo table /nh | sort /R /+64 | findstr/n ^^|findstr "^[1-9]: ^1[0]:" >> %logfile%

:: Add spacing for readability

echo. >> %logfile%
echo ============================================================================== >> %logfile%
echo. >> %logfile%
 
Here's a sample of the output, %PROTOP%\log\mem_usage.log:

Usage

This batch file is meant to run from your task scheduler at the desired frequency (like every 15 minutes). When called, it finds the top 10 memory-using processes and appends them to the log. The log includes the command's name, the PID, the Session Name, Session number, and Memory Usage.
There are several ways to see which processes consume how much memory on Windows, but that data is not tracked over time. If your server crashes due to memory issues, this log can reveal the highest memory using processes running just before the crash.  It can also reveal which processes consistently use more memory than others.