High memory usage

It cost over 5Gib memory when BotEngine starting first memory reading in 64bit client. But in Sanderling for 32bit client, it only needs 1Gib memory.

Before the first memory reading, the library searches for the root of the UI tree. The program uses some extra memory and CPU in this inition phase.

I ran a test to see the memory usage on startup. Microsoft Process Explorer showed about 2.2 Gigabytes peak memory usage.

The graph in the screenshot visualizes the memory use over time.

I think the memory usage there can be significantly reduced with a specialized implementation of the search for the UI root address: Sanderling/Program.cs at edeea9c38331c37e8e78f3420b5a17861f48ffe2 · Arcitectus/Sanderling · GitHub

I found an implementation with reduced memory usage. With the new version, the peak usage was about 270 Megabytes:

reduce memory usage

I updated the example projects to integrate this new version of the memory reading.

I tried the new version 2020-02-06.read-memory-64-bit.zip, but it shows error

PS D:\Download\2020-02-06.read-memory-64-bit> .\read-memory-64-bit.exe read-memory-eve-online --pid=9760
Unhandled exception. System.ArgumentException: Parameter is not valid.
   at System.Drawing.SafeNativeMethods.Gdip.CheckStatus(Int32 status)
   at System.Drawing.Bitmap..ctor(Int32 width, Int32 height, PixelFormat format)
   at read_memory_64_bit.Program.GetScreenshotOfWindowClientAreaAsBitmap(IntPtr windowHandle) in K:\Source\Repos\Sanderling\implement\read-memory-64-bit\Program.cs:line 337
   at read_memory_64_bit.Program.GetProcessSampleFileFromProcessId(Int32 processId) in K:\Source\Repos\Sanderling\implement\read-memory-64-bit\Program.cs:line 237
   at read_memory_64_bit.Program.<>c__DisplayClass2_3.<Main>g__GetRootAddressesAndMemoryReader|5() in K:\Source\Repos\Sanderling\implement\read-memory-64-bit\Program.cs:line 93
   at read_memory_64_bit.Program.<>c__DisplayClass2_2.<Main>b__4() in K:\Source\Repos\Sanderling\implement\read-memory-64-bit\Program.cs:line 133
   at McMaster.Extensions.CommandLineUtils.CommandLineApplicationExtensions.<>c__DisplayClass10_0.<OnExecute>b__0()
   at McMaster.Extensions.CommandLineUtils.CommandLineApplication.<>c__DisplayClass148_0.<OnExecute>b__0(CancellationToken _)
   at McMaster.Extensions.CommandLineUtils.CommandLineApplication.ExecuteAsync(String[] args, CancellationToken cancellationToken)
   at McMaster.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args)
   at read_memory_64_bit.Program.Main(String[] args) in K:\Source\Repos\Sanderling\implement\read-memory-64-bit\Program.cs:line 230
PS D:\Download\2020-02-06.read-memory-64-bit>

That error message looks like the error depends on the part taking the screenshots of the game client window.

I did some live testing here:
When I use read-memory-eve-online on a game client with minimized window, I also get a crash by exception out of GetScreenshotOfWindowClientAreaAsBitmap.

I don’t see this error after restoring the game client window.

What do you get when you run the command while the game client window is visible?

I updated the guides to prevent this problem in the future: Refine guide · Viir/bots@3af6103 · GitHub

It works. It still cost over 4000m memory. But it better then before.
WJ@}L7VM33W%J}{7RIZFR4V.png