Solving GPUView 4000 was unexpected at this time error. 5


Also in Spanish “No se esperaba 4000 en este momento”

Turns out GPUView’s latest log.cmd that comes with Windows ADK for Windows 10 is quite moronic and US-centric.

This error happens because the script at C:\Program Files (x86)\Windows Kits\10\Windows Performance Toolkit\gpuview\log.cmd calls systeminfo:

systeminfo > me.txt

findstr /sipn /C:”Total Physical Memory” me.txt > me2.txt

REM TRACE_LOGGING_MEMORY will hold the amount of physical memory on this machine.

for /f “tokens=6 delims=: ” %%a in (me2.txt) do set TRACE_LOGGING_MEMORY=%%a

del me.txt

del me2.txt

set TRACE_LOGGING_MEMORY=%TRACE_LOGGING_MEMORY:,=%

to obtain the amount of total GB memory in your system. However in a non-US machine systeminfo will dump to me.txt in the system’s language (in my case, Spanish) so the script tries to look for “Total Physical Memory” instead of “Cantidad total de memoria física” (or whatever your language is).

Additionally, the script won’t handle . and , delimiters regionalizations well (i.e. a thousand with five cents in some countries is written as 1.000,05 while in others is written as 1,000.05)

This causes the batch variable “TRACE_LOGGING_MEMORY” to be filled with garbage (or be left empty) which raises the 4000 error later on.

You can try to fix the script so that it handles everything properly. Or you can just hack it for your machine, which is what I did. The script assumes if you have <= 2GB you should use small buffers, >2GB <=4GB medium buffers, and >4GB large buffers. I have 16GB RAM, so I need large buffers, I just need to edit log.cmd and add a “goto Set_Large_Buffers”:

goto Set_Large_Buffers

REM

REM For buffers sizes

REM

REM The cutoff for large bufers 5G, Medium buffers 2G physical memory

if %TRACE_LOGGING_MEMORY% Gtr 4000 goto Set_Large_Buffers

if %TRACE_LOGGING_MEMORY% Gtr 2000 goto Set_Medium_Buffers

REM echo !Using Small Buffers Memory Footprint here!

set TRACE_LARGE_BUFFERS=-BufferSize 1024 -MinBuffers 30 -MaxBuffers 120

set TRACE_STAND_BUFFERS=-BufferSize 1024 -MinBuffers 25 -MaxBuffers 25

goto Done_With_It

:Set_Medium_Buffers

REM echo !Using Meidum Buffers Memory Footprint here!

set TRACE_LARGE_BUFFERS=-BufferSize 1024 -MinBuffers 60 -MaxBuffers 240

set TRACE_STAND_BUFFERS=-BufferSize 1024 -MinBuffers 50 -MaxBuffers 50

goto Done_With_It

:Set_Large_Buffers

REM echo !Using Large Buffers Memory Footprint here!

set TRACE_LARGE_BUFFERS=-BufferSize 1024 -MinBuffers 120 -MaxBuffers 480

set TRACE_STAND_BUFFERS=-BufferSize 1024 -MinBuffers 100 -MaxBuffers 100

:Done_With_It

The “goto Set_Large_Buffers” I added at the top ensures the “if %TRACE_LOGGING_MEMORY% Gtr 4000 goto Set_Large_Buffers” is never reached, thus skipping the error while working as intended.

And there you go. Now GPUView works for me. Hope this helps someone. Go profiling now.

Cheers


5 thoughts on “Solving GPUView 4000 was unexpected at this time error.

  • Oscar

    Fine, thanks!

    In my spanish Windows I substituted the offending line with (note the extra space between double quotes):

    findstr /sipn /C:” memor” me.txt > me2.txt

    Both in “log.cmd” and “log_mem.cmd”.

    This way it can be accessed form en-us and from es-es systems, with no guarrantee of future, of course.

  • Leo

    I got the similar error. But on russian it’s sound like:
    Непредвиденное появление: 4000.

    GPUView, log.cmd
    Thanks for your solution!

Comments are closed.