# Losing fonts



## bch (Oct 2, 2018)

Hello, 

I am running FreeBSD 11.2 on a Thinkpad X230 with WindowMaker/ZFS.  My problem is that FreeBSD is losing its font i.e. after some time, terminal emulator show only a black window  (especially with TrueType Fonts).  I've attached an imaged that shows xterm and emacs session.  I can observe this behavior after many suspend & resume cycles or doing something with heavy I/O load (i.e. rsync backup of 200-300 GB).  I've observed that the wired memory in top(1)() is consuming almost 100% of the entire memory (i first used 8 GB RAM, and later upgraded to 16GB).  

Some more observations: it seems that ZFS is using a lot of memory (when doing heavy i/o workloads) i haven't set any specific value in vfs.zfs.arc_max.  So, my impression is that too much memory is used and X11/fonts etc are swapped out and not reachable.  I tried to verify this with lowering the arc_max value a bit and the problem seemed to be not triggered "immediately" (I've tested this for a few hours and with one rsync actiivity).  I also tried turning swap entirely off but this crashed X11 somehow (not sure why).  But even if the font/X11 component is swapped out, i guess that the font should appear (with some delay)? 

I am thankful to any hints.  I haven't seen any related problem reports and i am not sure if i made any mistake in my basic system setup.  I've tried to capture some information that might be helpful:


I am using the inconsolata font, my .Xdefaults looks like that:


```
XTerm*faceName:inconsolata:style=Regular:size=14
```

When using a monospace font (no TrueType Font), the problem is not that acute.  My browser is often not affected by this (interestingly; but my guess is that it's activity makes it less likely to be swapped out). 

I tried to capture the system status with top and that is the system load at the time where the screenshot was generated: 

```
last pid:  1352;  load averages:  2.14,  1.38,  0.72  up 0+00:13:38    19:34:42
67 processes:  2 running, 65 sleeping

Mem: 62M Active, 141M Inact, 31M Laundry, 15G Wired, 141M Free
ARC: 13G Total, 241M MFU, 13G MRU, 99M Anon, 46M Header, 462M Other
     12G Compressed, 13G Uncompressed, 1.11:1 Ratio
Swap: 8192M Total, 460M Used, 7732M Free, 5% Inuse


  PID USERNAME    THR PRI NICE   SIZE    RES STATE   C   TIME    WCPU COMMAND
 1342 bch           1  32    0   132M  7944K select  3   0:28  18.90% rsync
 1252 bch           1  29    0 24168K  4168K select  2   1:37  16.46% rsync
 1253 bch           1  28    0 22120K  3384K select  3   1:49  15.09% rsync
 1341 bch           1  29    0   104M 17312K CPU2    2   0:06   9.18% rsync
 1340 bch           1  21    0 19304K  8368K select  1   0:05   3.66% sshd
 1113 root          3  20    0 84384K 25492K select  3   0:04   0.59% Xorg
 1351 bch           1  20    0  7144K  3144K wait    0   0:00   0.49% sh
 1349 bch           1  21    0 15596K 10700K select  1   0:00   0.39% xterm
 1251 bch           1  20    0 13160K  4808K select  3   0:03   0.10% sshd
 1233 bch          52  20    0  1564M 78276K select  0   0:20   0.00% firefox
 1240 bch          20  20    0  1358M 22812K select  1   0:09   0.00% firefox
 1119 haldaemon     2  20    0 16240K  3512K select  3   0:07   0.00% hald
 1236 bch          20  20    0  1365M 63240K select  0   0:04   0.00% firefox
 1212 bch           5  20    0   138M 27832K select  2   0:03   0.00% emacs-26.
 1239 bch          20  20    0  1291M 20044K select  2   0:01   0.00% firefox
 1182 bch           1  20    0 29476K  8080K select  1   0:01   0.00% wmaker
  893 root          1  20    0 12452K 12548K select  2   0:00   0.00% ntpd
 1220 bch           1  20    0  7324K  2420K select  3   0:00   0.00% dbus-daem
[/CODE}

I've also attached the dmesg, and my loaded kernel modules are: 

[CODE]Id Refs Address            Size     Name
 1   76 0xffffffff80200000 2036810  kernel
 2    1 0xffffffff82238000 af98     aesni.ko
 3    1 0xffffffff82243000 1e0d8    geom_eli.ko
 4    1 0xffffffff82262000 381080   zfs.ko
 5    2 0xffffffff825e4000 a380     opensolaris.ko
 6    2 0xffffffff825ef000 22f48    drm.ko
 7    2 0xffffffff82612000 73320    drm2.ko
 8    5 0xffffffff82686000 6b00     iicbus.ko
 9    1 0xffffffff8268d000 be40     i915.ko
10    1 0xffffffff82699000 e5b78    i915kms.ko
11    2 0xffffffff8277f000 4c98     iicbb.ko
12    2 0xffffffff82784000 3690     iic.ko
13    1 0xffffffff82788000 72d8     acpi_ibm.ko
14    1 0xffffffff82790000 3f48     acpi_dock.ko
15    1 0xffffffff82821000 c60      coretemp.ko
16    1 0xffffffff82822000 32d048   vmm.ko
17    1 0xffffffff82b50000 24a0     if_tap.ko
18    1 0xffffffff82b53000 5fb8     if_bridge.ko
19    1 0xffffffff82b59000 3b78     bridgestp.ko
20    1 0xffffffff82b5d000 3698     ng_ubt.ko
21    5 0xffffffff82b61000 9a20     netgraph.ko
22    1 0xffffffff82b6b000 8e78     ng_hci.ko
23    3 0xffffffff82b74000 95c      ng_bluetooth.ko
24    1 0xffffffff82b75000 bc0e     ng_l2cap.ko
25    1 0xffffffff82b81000 176a8    ng_btsocket.ko
26    1 0xffffffff82b99000 1d40     ng_socket.ko
27    1 0xffffffff82b9b000 2e4a8    pf.ko
```


----------



## tankist02 (Oct 2, 2018)

In my experience after some time ZFS would always consume all memory and the system becomes unusable because regular applications ran out of memory. Setting limit in arc_max helped a lot.


----------



## rigoletto@ (Oct 2, 2018)

The ZFS ARC will use 100% _minus_ 1GB of the RAM, but it is supposed to dynamically release ARC when another software needs RAM. However this feature seems to not be properly working for many users, and setting `vfs.zfs.arc_max` is usually enough to workaround it.

If you have 16GB RAM you could try limiting it to 12GB, but in practice you need to test. Limiting to 14GB may be enough but eventually you may need to limit more, like to 8GB.


----------



## bch (Oct 3, 2018)

Thanks for your answers.  Ok, I will limit arc_max and keep an eye on this problem.  I wonder why ARC is not releasing memory.


----------



## SirDice (Oct 3, 2018)

bch said:


> So, my impression is that too much memory is used and X11/fonts etc are swapped out and not reachable.


Why would it be unreachable? It's just memory, even if it's swapped out.


----------



## bch (Oct 3, 2018)

SirDice said:


> Why would it be unreachable? It's just memory, even if it's swapped out.


I don't know why, that's why i am asking.  Maybe, xorg expects the fonts to be in memory somewhere? What I would expect is that drawing an image on the screen has  a short delay if something is swapped out (as you said: it's just memory).  But what actually happens is that no fonts appear.


----------

