0
votes

I've successfully set up a self-hosted agent to build my pipelines from Azure DevOps. However, now I need to increase the default 1GB memory that my machine assigns to the docker container.

If I run a docker and check its memory:

docker run mcr.microsoft.com/dotnet/framework/runtime:4.8-windowsservercore-ltsc2019 wmic MemoryChip get BankLabel, Capacity, MemoryType, TypeDetail, Speed

I get

BankLabel  Capacity    MemoryType  Speed  TypeDetail
None       1073741824  0                  4

Which is the default 1GB memory space (running on Windows host). If I set the -m option in docker run:

docker container run -m 4294967296 mcr.microsoft.com/dotnet/framework/runtime:4.8-windowsservercore-ltsc2019 wmic MemoryChip get BankLabel, Capacity, MemoryType, TypeDetail, Speed

I get

BankLabel  Capacity    MemoryType  Speed  TypeDetail
None       4160749568  0                  4
None       671088640   0                  4

This is not exactly what I was expecting (I was expecting something like the first line), but I can live with it as I do not need an exact amount of memory, just more than 1GB. Since the -m option works fine for me when starting the docker on the command line, I added it as an option to my container (I also added --cpus to check that the options take effect):

container: 
    image: mcr.microsoft.com/dotnet/framework/runtime:4.8-windowsservercore-ltsc2019
    options: -m 4294967296 --cpus="8"

The pipeline that I have configured on a yml file consists of two jobs, one with the default docker container settings and one with the -m and --cpus options:

jobs:
- job: windowsbuild
  displayName: "Windows build"
  pool:
    name: 'Default'
  container: 
    image: mcr.microsoft.com/dotnet/framework/runtime:4.8-windowsservercore-ltsc2019
    options: -m 4294967296 --cpus="8"
  steps:
  - script:
      systeminfo
    displayName: 'System information'
  - script:
      wmic MemoryChip get BankLabel, Capacity, MemoryType, TypeDetail, Speed
    displayName: 'Memory information'
  - script:
      wmic cpu get caption, deviceid, name, numberofcores, numberofenabledcore, numberoflogicalprocessors, maxclockspeed, status
    displayName: 'CPU information'
  - script: |
      mkdir build
      cd build
      cmake ..
      cmake --build . --config RelWithDebInfo
      RelWithDebInfo\hello_world.exe
    displayName: 'Hello world compilation'
- job: secondjob
  displayName: "Second job"
  dependsOn: windowsbuild
  pool:
    name: 'Default'
  container: 
    image: mcr.microsoft.com/dotnet/framework/runtime:4.8-windowsservercore-ltsc2019
  steps:
  - script:
      systeminfo
    displayName: 'System information'
  - script:
      wmic MemoryChip get BankLabel, Capacity, MemoryType, TypeDetail, Speed
    displayName: 'Memory information'
  - script:
      wmic cpu get caption, deviceid, name, numberofcores, numberofenabledcore, numberoflogicalprocessors, maxclockspeed, status
    displayName: 'CPU information'

To my surprise, both jobs give the same output for the memory command. And this output is 1GB, ignoring the -m flag for the "windows build" job:

BankLabel  Capacity    MemoryType  Speed  TypeDetail   
None       1073741824  0                  4 

However, the CPUs command did take effect. In the "Windows build" job I get:

Caption                                 DeviceID  MaxClockSpeed  Name                                     NumberOfCores  NumberOfEnabledCore  NumberOfLogicalProcessors  Status   
Intel64 Family 6 Model 158 Stepping 10  CPU0      3192           Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz  4              8                    8                          OK 

while in the "Second job" job I get:

Caption                                 DeviceID  MaxClockSpeed  Name                                     NumberOfCores  NumberOfEnabledCore  NumberOfLogicalProcessors  Status   
Intel64 Family 6 Model 158 Stepping 10  CPU0      3192           Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz  1              2                    2                          OK

So each environment has the right numbers of CPUs.

Any idea on what am I doing wrong with the memory part?

1
Hi @apalomer, Just checking in to see whether this issue is still blocking you now? Any update for this issue? - Vito Liu

1 Answers

0
votes

I have change the script, you could try it and then kindly share the result here.

trigger: none
jobs:
- job: windowsbuild
  displayName: "Windows build"
  pool:
    name: 'Default'
  container: 
    image: mcr.microsoft.com/dotnet/framework/runtime:4.8-windowsservercore-ltsc2019
    
  steps:
  - task: CmdLine@2
    inputs:
      script: |
        systeminfo
        
        wmic MemoryChip get BankLabel, Capacity, MemoryType, TypeDetail, Speed
        
        wmic cpu get caption, deviceid, name, numberofcores, numberofenabledcore, numberoflogicalprocessors, maxclockspeed, status
 
- job: secondjob
  displayName: "Second job"
  dependsOn: windowsbuild
  pool:
    name: 'Default'
  container: 
    image: mcr.microsoft.com/dotnet/framework/runtime:4.8-windowsservercore-ltsc2019
    options: -m 4294967296 
  steps:
  - task: CmdLine@2
    inputs:
      script: |
        systeminfo
        
        wmic MemoryChip get BankLabel, Capacity, MemoryType, TypeDetail, Speed
        
        wmic cpu get caption, deviceid, name, numberofcores, numberofenabledcore, numberoflogicalprocessors, maxclockspeed, status

Result:

enter image description here