# Writing to routing socket: Cannot allocate memory



## escape (Jul 30, 2022)

Building 13.1-STABLE world had an error in it, it still completed and the install was in error (2GB RAM was not enough to compile llvm). A `make -DWITHOUT_CLEAN buildworld` without `TARGET_ARCH=aarch64` had to be made before the install was successful. After I'm not able to set the default route (to update the `/usr/src`):


```
# route add -net 0.0.0.0 192.168.x.x
route: writing to routing socket: Cannot allocate memory
add net 0.0.0.0: gateway 192.168.x.x fib 0: Cannot allocate memory

# uname -a
FreeBSD arm64bsd 13.1-STABLE FreeBSD 13.1-STABLE #5 stable/13-fde05f986 ...
```

There is a "_Cannot allocate memory_" . Does anyone know what it could be?

The next kernel compile stopped in console message `Jul 30 04:00:30 ------- kernel: pid 49245 (c++), jid 0, uid 0, was killed: failed to reclaim memory` after copying the `/usr/src` from LAN. I'm assuming the world should be built elsewhere to overcome this problem if the memory problem cannot be fixed.

Does anyone know how to fix this?

e


----------



## escape (Aug 7, 2022)

It has been a long time because the compilation takes multiple days in ARM64 equipped with 1024 MB RAM. The swap was not used at all, maby because of the same error. The compile ended in:

`Aug  7 19:23:14 ----- kernel: pid 92060 (cc), jid 0, uid 0, was killed: failed to reclaim memory`

The part in error (`/usr/src/lib/msun/tests/ctrig_test.c -o ctrig_test.o`) was now compiled without the error when the file `/usr/src/sys/sys/param.h` was modified and `MAXPHYS` set from 1024*1024 back to 128*1024:

`#define MAXPHYS               (128 * 1024)`

This made the compile to proceed. The results again take multiple days.

This is 13.1-RELEASE.


----------



## escape (Aug 7, 2022)

Failed again similarly as with the previous `MAXPHYS` setting. The swap area is mostly not used, only tens of megabytes. The 13.1-STABLE was partly installed from compiled code. Is the swap unusable? What causes the `"indefinite wait buffer"`?


```
$swapinfo
Device          1K-blocks     Used    Avail Capacity
/dev/md0p1        2654168     1836  2652332     0%
/dev/md1p1        1569464     1620  1567844     0%
Total             4223632     3456  4220176     0%
```


```
cc -target aarch64-unknown-freebsd13.1 --sysroot=/usr/obj/usr/src/arm64.aarch64/tmp
-B/usr/obj/usr/src/arm64.aarch64/tmp/usr/bin  -O2 -pipe -fno-common   -DHAVE_FENV_H
-I/usr/src/contrib/netbsd-tests/lib/libc/gen -D__HAVE_LONG_DOUBLE -fno-builtin -DUSE_BUILTIN_FMAF
-DUSE_BUILTIN_FMA -DUSE_BUILTIN_FMAXF -DUSE_BUILTIN_FMAX -DUSE_BUILTIN_FMINF -DUSE_BUILTIN_FMIN
-DUSE_BUILTIN_SQRTF -DUSE_BUILTIN_SQRT -DLDBL_PREC=113 -fPIE -g -MD  -MF.depend.ctrig_test.ctrig_test.o
-MTctrig_test.o -std=gnu99 -Wno-format-zero-length -fstack-protector-strong -Wno-error=ignored-pragmas
-Wsystem-headers -Werror -Wall -Wno-format-y2k -W -Wno-unused-parameter -Wstrict-prototypes
-Wmissing-prototypes -Wpointer-arith -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch -Wshadow
-Wunused-parameter -Wcast-align -Wchar-subscripts -Wnested-externs -Wredundant-decls
-Wold-style-definition -Wno-pointer-sign -Wno-unknown-pragmas -Wmissing-variable-declarations
-Wthread-safety -Wno-empty-body -Wno-string-plus-int -Wno-unused-const-variable
-Wno-error=unused-but-set-variable  -Qunused-arguments  -c /usr/src/lib/msun/tests/ctrig_test.c -o
ctrig_test.o

/usr/src/lib/msun/tests/ctrig_test.c:43:14: warning: '#pragma FENV_ACCESS' is not supported on this target
- ignored [-Wignored-pragmas]

#pragma STDC FENV_ACCESS        ON
             ^

Aug  7 23:58:51 ----- kernel: pid 58346 (cc), jid 0, uid 0, was killed: failed to reclaim memory
Aug  7 23:58:56 ----- kernel: pid 52716 (csh), jid 0, uid 0, was killed: failed to reclaim memory
Aug  7 23:58:58 ----- kernel: pid 36151 (csh), jid 0, uid 0, was killed: failed to reclaim memory
swap_pager: indefinite wait buffer: bufobj: 0, blkno: 6196, size: 4096
swap_pager: indefinite wait buffer: bufobj: 0, blkno: 669788, size: 8192
Aug  7 23:59:04 ----- kernel: pid 790 (ntpd), jid 0, uid 123, was killed: failed to reclaim memory
Aug  7 23:59:05 ----- kernel: pid 92042 (sshd), jid 0, uid 1000, was killed: failed to reclaim memory
Aug  7 23:59:11 ----- kernel: pid 92039 (sshd), jid 0, uid 0, was killed: failed to reclaim memory
Aug  7 23:59:13 ----- kernel: pid 67721 (bash), jid 0, uid 0, was killed: failed to reclaim memory
Aug  7 23:59:15 ----- kernel: pid 58347 (top), jid 0, uid 0, was killed: failed to reclaim memory
swap_pager: indefinite wait buffer: bufobj: 0, blkno: 669588, size: 16384
Aug  7 23:59:17 ----- kernel: pid 36150 (login), jid 0, uid 0, was killed: failed to reclaim memory
Aug  7 23:59:21 ----- kernel: pid 52715 (su), jid 0, uid 0, was killed: failed to reclaim memory
swap_pager: indefinite wait buffer: bufobj: 0, blkno: 669788, size: 8192
swap_pager: indefinite wait buffer: bufobj: 0, blkno: 664614, size: 4096
Aug  7 23:59:25 ----- kernel: pid 92043 (sh), jid 0, uid 1000, was killed: failed to reclaim memory
swap_pager: indefinite wait buffer: bufobj: 0, blkno: 668788, size: 8192
Aug  7 23:59:27 ----- kernel: pid 39460 (sh), jid 0, uid 0, was killed: failed to reclaim memory
```


----------



## oOiOo (Aug 8, 2022)

I had the same problem after updating to 13.1 when building nanobsd (amd64): 2GB is not enough to compile llvm. I fixed that by reducing the number of threads (make -j2 on a 4 threads machine in my case). There was not much impact on compile time.


----------

