Disabling swap on AGX

Hi, are there any large downsides to disabling swap on the AGX? During normal operation, we are not close to using all memory. However, in the case of a future memory leak, I think it would be preferred to run out of memory and have the OOM killer kill the program. That way we would see that it crashed in the logs and could address it. Are there any other issues we might run into with swap disabled?

Mostly this is ok, and you could just try it to find out. Sometimes though a program might require swap, though most won’t care.

Do consider the output of this command:
lsblk -f

You will find zram which is compressed data in RAM pretending to be a swap file or partition (most of the time; zram is more useful than just that purpose). So if you leave zram enabled, you still have swap without using disk space. This might or might not be useful to you.

You should know that most kernel space drivers require physical RAM and connot use virtual RAM. The NVIDIA GPU driver is one such device, so no amount of swap would help with something like training that needs to much RAM. Indirectly though, the other program might use virtual memory and make more physical memory available for the GPU.

In the case of swap to an actual partition or file, and if that partition or file is on a solid state device (such as eMMC or NVMe), then you could save on the life of that solid state memory by not swapping to it. zram won’t have any reduction in life by existing or being used, and is much faster than eMMC or NVMe memory, so again zram might be useful (although you might reduce the amount of zram if you don’t need the defaults).

Most programs can and will be killed by OOM. What you have to look out for though is when drivers and kernel space cannot operate, in which case you’ll get a kernel panic and complete lockup or reboot should some drivers fail. That’s kind of an extreme case though.

My desktop PC has plenty of RAM, so I run without swap most of the time. I do have a swap partition, but I only manually enable it in extreme cases (for example, FreeCAD on some content might require over 100 GB of RAM, and swap is fine for that).

The short answer is that there isn’t much downside to disabling swap most of the time. A better answer would be to find out what you hope to accomplish. If you are looking for things like memory leaks, then there might be other tools like Valgrind which are more useful. The answer would still differ in cases where your device is out in the field versus in your development area of the office. Keep in mind that OOM killer won’t necessarily kill the program you want to kill…for user space content of one program running out of memory, I would say the odds are in favor of killing that program, but it isn’t a guarantee.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.