swap partition closes
is ready to adjust the utilization of the swap partition under Linux.
executing swapoff-a-v under Linux reports the following error:
swapoff: /dev/mapper/cryptswap1: swapoff failed: Cannot allocate memory
error cause analysis:
can be seen from the above information, the current Linux/dev/mapper/cryptswap1 this device as a swap partition, if the current swap partition instead of the current remaining capacity is greater than the system memory, will quote this mistake, because at the time of closing swap partition, all need to partition data written to the memory, if the memory capacity is insufficient, will cause the error.
method 1: free memory cache
# sync ; echo 3 > /proc/sys/vm/drop_caches #先把内存数据回写到磁盘，然后释放内存缓存
drop_caches accepted parameters are
3, empting pagecache, slab object, pagecahce, and slab object
parameters explanation to this file can be found from https://github.com/torvalds/linux/blob/master/Documentation/sysctl/vm.txt: p>
drop_caches Writing to this will cause the kernel to drop clean caches, as well as reclaimable slab objects like dentries and inodes. Once dropped, their memory becomes free. To free pagecache: echo 1 > /proc/sys/vm/drop_caches To free reclaimable slab objects (includes dentries and inodes): echo 2 > /proc/sys/vm/drop_caches To free slab objects and pagecache: echo 3 > /proc/sys/vm/drop_caches
dirty state memory cache will not be freed. To free as much memory cache as possible, first execute the command
sync to reduce memory cache in the dirty state. If disable, the input parameter
4, note that
0 is not acceptable:
the above method may not work if you use too much swap partition.
method 2: allows memory overcommit
overcommit_memory controls “when user space requests memory, overcommit and approve:
When this flag is 0, the kernel attempts to estimate the amount of free memory left when userspace requests more memory. When this flag is 1, the kernel pretends there is always enough memory until it actually runs out. When this flag is 2, the kernel uses a "never overcommit" policy that attempts to prevent any overcommit of memory. Note that user_reserve_kbytes affects this policy.
2 means overcommit is not allowed. At this point, if swap is stopped, the available memory is reduced and the user space memory request may trigger overcommit to be rejected.
reproduced in: https://www.cnblogs.com/yjt1993/p/11163679.html p>
- Kvm internal error: process exited ：cannot set up guest memory ‘pc.ram‘:Cannot allocate memory
- os::commit_memory(0x0000000538000000, 11408506880, 0) failed； error=‘Cannot allocate memory‘
- Remember a virtual machine expansion swapoff failed: cannot allocate memory
- Server composer install error: proc_open(): fork failed-Cannot allocate memory
- Mysql cannot allocate memory for the buffer pool solution
- [Solved] Android compile error: cannot allocate memory
- The docker installation es reported an error of failed; error = – cannot allocate memory ‘(errno = 12)
- CentOS execution command error: – bash: fork: cannot allocate memory processing / viewing process number
- RuntimeError: CUDA out of memory. Tried to allocate 600.00 MiB (GPU 0； 23.69 GiB total capacity)
- WebHost failed to process a request.Memory gates checking failed because the free memory (140656640 …
- Fatal error: Newspace:: rebalance allocation failed – process out of memory (memory overflow)
- Hot Swap failed:add method not implemented
- Hbase Native memory allocation (mmap) failed to map xxx bytes for committing reserved memory
- Failed to extend swap file from 0 kb to xxx kb.
- [Linux] e297: write error in swap file solution
- The difference, cause and solution of memory overflow and memory leak
- write error in swap file problem solving
- Error analysis of swap file “*. SWP” already exists! When editing files with VIM
- EXSI6.0 virtual machine swap error causes it to fail to start
- docker Error creating default “bridge“ network: failed to allocate gateway Address already in use