На неслабом, в общем то сервере на любую команду выдается
-bash: fork: Cannot allocate memory
в редкий момент просветления получил top
top - 17:52:36 up 50 days, 6:13, 1 user, load average: 1.01, 1.13, 1.03
Tasks: 1868 total, 2 running, 1866 sleeping, 0 stopped, 0 zombie
%Cpu(s): 0.8 us, 33.9 sy, 0.0 ni, 64.4 id, 0.8 wa, 0.0 hi, 0.0 si, 0.2 st
KiB Mem : 2052332 total, 59784 free, 1930936 used, 61612 buff/cache
KiB Swap: 0 total, 0 free, 0 used. 12570 avail Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
37 root 20 0 0 0 0 R 52.4 0.0 126:43.98 kswapd0
5553 mysql 20 0 691788 147584 0 S 6.9 7.2 31:10.36 mysqld
15691 root 20 0 48052 3160 556 R 4.4 0.2 0:00.43 top
455 root 20 0 572420 16564 0 S 1.6 0.8 55:10.43 containerd
26602 root 20 0 298640 15884 0 S 1.6 0.8 6:07.22 php
5456 root 20 0 725056 18412 0 S 1.3 0.9 7:01.30 core
736 root 20 0 417512 141040 0 S 0.9 6.9 233:22.80 fail2ban-s+
5667 root 20 0 1363264 113900 0 S 0.9 5.5 26:30.04 core
7 root 20 0 0 0 0 S 0.3 0.0 31:45.10 rcu_sched
142 root 20 0 0 0 0 S 0.3 0.0 3:11.06 jbd2/vda5-8
854 ntp 20 0 102104 584 0 S 0.3 0.0 4:06.90 ntpd
15602 root 20 0 0 0 0 S 0.3 0.0 0:00.10 kworker/u4+
1 root 20 0 270292 67236 0 S 0.0 3.3 1:17.53 systemd
2 root 20 0 0 0 0 S 0.0 0.0 0:00.36 kthreadd
3 root 20 0 0 0 0 S 0.0 0.0 2:17.78 ksoftirqd/0
5 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kworker/0:+
8 root 20 0 0 0 0 S 0.0 0.0 0:00.00 rcu_bh
лично мне непонятно — свапа в системе вроде как нет, но половину CPU съедает процесс kswapd0.
Еще очень много sleeping tasks. Я подозреваю, что они возникли так:
На сревере крутится php процесс, который хотелось бы иметь постоянно работающим. Там стоит set_time_limit(0); Но, понятно, что это не гарантирует от разных форсмажоров. Потому, этот процесс запускается кроном каждую минуту и первым делом смотрит — есть ли дубль в ps axu. Если есть — то прекращает работу. Вероятно, в какой-то момент система оказалась сильно загруженной и процесс хоть и запустился, но не смог даже проверить на дубль. Через 1 минуту это повторилось ну и так далее.
Значит, у меня 2 вопроса.
1. Поможет ли в описанной ситуации создание свап файла? Или он таки уже есть?
2. Как организовать чтоб нужный php скрипт гарантировано выполнялся, а в случае краха — перезапускался?
Спасибо.
In my case, OS was running out of PID instead of memory, the error message was the same though.
The default value of max PID number is 32768, to view the value, run
cat /proc/sys/kernel/pid_max
To change the max pid number, run
echo 100000 > /proc/sys/kernel/pid_max
In my scenario, the root cause was that one java prcocess spawned 18k+ threads( in linux kernel, thread is essentially a process), to find out the thread count of each process, run
ps -eo nlwp,pid,args --sort nlwp
Windows Server 2008 R2 Service Pack 1 Windows Server 2008 R2 Enterprise Windows Server 2008 R2 Datacenter Windows Server 2008 R2 for Itanium-Based Systems Windows Server 2008 R2 Foundation Windows Server 2008 R2 Standard Windows Server 2008 R2 Web Edition Windows 7 Service Pack 1 Windows 7 Enterprise Windows 7 Home Basic Windows 7 Home Premium Windows 7 Professional Windows 7 Starter Windows 7 Ultimate Windows 8 Windows 8 Enterprise Windows 8 Pro Windows Server 2012 Datacenter Windows Server 2012 Datacenter Windows Server 2012 Essentials Windows Server 2012 Standard Windows Server 2012 Standard More…Less
Symptoms
Assume that you have a computer that is running Subsystem for UNIX-based Applications (SUA). The computer is running one of the following operating systems:
-
Windows 7 Service Pack 1 (SP1)
-
Windows Server 2008 R2 Service Pack 1 (SP1)
-
Windows 8
-
Windows Server 2012
When you try to run a shell script to create many environment variables, the script fails and you receive an error message that resembles the following:
Cannot Allocate Memory
Note This issue only occurs when the environment variable block size is over 64 kilobytes (KB).
Cause
This issue occurs because the string length that is specified for the RtlSetEnvironmentVar API is incorrect when the environment variable block size is over 64 KB.
Resolution
This hotfix is also available at Microsoft Update Catalog
Hotfix information
A supported hotfix is available from Microsoft. However, this hotfix is intended to correct only the problem that is described in this article. Apply this hotfix only to systems that are experiencing the problem described in this article. This hotfix might receive additional testing. Therefore, if you are not severely affected by this problem, we recommend that you wait for the next software update that contains this hotfix.
If the hotfix is available for download, there is a «Hotfix download available» section at the top of this Knowledge Base article. If this section does not appear, contact Microsoft Customer Service and Support to obtain the hotfix.
Note If additional issues occur or if any troubleshooting is required, you might have to create a separate service request. The usual support costs will apply to additional support questions and issues that do not qualify for this specific hotfix. For a complete list of Microsoft Customer Service and Support telephone numbers or to create a separate service request, visit the following Microsoft website:
http://support.microsoft.com/contactus/?ws=supportNote The «Hotfix download available» form displays the languages for which the hotfix is available. If you do not see your language, it is because a hotfix is not available for that language.
Prerequisites
To apply this hotfix, you must be running one of the following operating systems:
-
Windows 7 Service Pack 1 (SP1)
-
Windows Server 2008 R2 Service Pack 1 (SP1)
-
Windows 8
-
Windows Server 2012
Additionally, you must have Utilities and Software Development Kit (SDK) for Subsystem for UNIX-based Applications installed.
For more information about how to obtain a Windows 7 or Windows Server 2008 R2 service pack, click the following article number to view the article in the Microsoft Knowledge Base:
976932Information about Service Pack 1 for Windows 7 and for Windows Server 2008 R2
Registry information
To apply this hotfix, you do not have to make any changes to the registry.
Restart requirement
You must restart the computer after you apply this hotfix.
Hotfix replacement information
This hotfix does not replace a previously released hotfix.
The global version of this hotfix installs files that have the attributes that are listed in the following tables. The dates and the times for these files are listed in Coordinated Universal Time (UTC). The dates and the times for these files on your local computer are displayed in your local time together with your current daylight saving time (DST) bias. Additionally, the dates and the times may change when you perform certain operations on the files.
Windows 7 and Windows Server 2008 R2 file information notes
Important Windows 7 hotfixes and Windows Server 2008 R2 hotfixes are included in the same packages. However, hotfixes on the Hotfix Request page are listed under both operating systems. To request the hotfix package that applies to one or both operating systems, select the hotfix that is listed under «Windows 7/Windows Server 2008 R2» on the page. Always refer to the «Applies To» section in articles to determine the actual operating system that each hotfix applies to.
-
The files that apply to a specific product, SR_Level (RTM, SPn), and service branch (LDR, GDR) can be identified by examining the file version numbers as shown in the following table:
Version
Product
Milestone
Service branch
6.1.760
1.22xxxWindows 7 and Windows Server 2008 R2
SP1
LDR
-
The MANIFEST files (.manifest) and the MUM files (.mum) that are installed for each environment are listed separately in the «Additional file information for Windows 7 and for Windows Server 2008 R2» section. MUM and MANIFEST files, and the associated security catalog (.cat) files, are extremely important to maintaining the state of the updated component. The security catalog files, for which the attributes are not listed, are signed with a Microsoft digital signature.
For all supported x86-based versions of Windows 7
|
File name |
File version |
File size |
Date |
Time |
Platform |
|---|---|---|---|---|---|
|
Psxdll.dll |
6.1.7601.22195 |
309,248 |
16-Dec-2012 |
18:37 |
x86 |
|
Psxdllsvr.dll |
6.1.7601.22195 |
357,888 |
16-Dec-2012 |
18:37 |
x86 |
|
Psxss.exe |
6.1.7601.22195 |
656,896 |
16-Dec-2012 |
14:43 |
x86 |
|
Sua-ppdlic.xrm-ms |
Not applicable |
2,981 |
16-Dec-2012 |
18:57 |
Not applicable |
For all supported x64-based versions of Windows 7 and of Windows Server 2008 R2
|
File name |
File version |
File size |
Date |
Time |
Platform |
|---|---|---|---|---|---|
|
Psxdll.dll |
6.1.7601.22195 |
330,240 |
16-Dec-2012 |
17:41 |
x64 |
|
Psxdllsvr.dll |
6.1.7601.22195 |
378,368 |
16-Dec-2012 |
17:41 |
x64 |
|
Psxss.exe |
6.1.7601.22195 |
849,408 |
16-Dec-2012 |
15:04 |
x64 |
|
Sua-ppdlic.xrm-ms |
Not applicable |
2,981 |
16-Dec-2012 |
18:07 |
Not applicable |
|
Psxdll.dll |
6.1.7601.22195 |
328,192 |
16-Dec-2012 |
18:37 |
x86 |
|
Psxdllsvr.dll |
6.1.7601.22195 |
376,832 |
16-Dec-2012 |
18:37 |
x86 |
|
Psxdll.dll |
6.1.7601.22195 |
328,192 |
16-Dec-2012 |
18:37 |
x86 |
For all supported IA-64-based versions of Windows Server 2008 R2
|
File name |
File version |
File size |
Date |
Time |
Platform |
|---|---|---|---|---|---|
|
Psxdll.dll |
6.1.7601.22195 |
718,848 |
16-Dec-2012 |
16:17 |
IA-64 |
|
Psxdllsvr.dll |
6.1.7601.22195 |
744,448 |
16-Dec-2012 |
16:17 |
IA-64 |
|
Psxss.exe |
6.1.7601.22195 |
1,649,664 |
16-Dec-2012 |
14:26 |
IA-64 |
|
Posixsscom.dll |
6.1.7601.22195 |
5,632 |
16-Dec-2012 |
14:42 |
x86 |
|
Psxdll.dll |
6.1.7601.22195 |
328,192 |
16-Dec-2012 |
18:37 |
x86 |
|
Psxdllsvr.dll |
6.1.7601.22195 |
376,832 |
16-Dec-2012 |
18:37 |
x86 |
Windows 8 and Windows Server 2012 file information notesImportant Windows 8 and Windows Server 2012 hotfixes are included in the same packages. However, only «Windows 8» is listed on the Hotfix Request page. To request the hotfix package that applies to one or both operating systems, select the hotfix that is listed under «Windows 8» on the page. Always refer to the «Applies To» section in articles to determine the actual operating system that each hotfix applies to.
-
The files that apply to a specific product, milestone (RTM,SPn), and service branch (LDR, GDR) can be identified by examining the file version numbers as shown in the following table:
Version
Product
Milestone
Service branch
6.2.920 0.20 xxx
Windows 8 and Windows Server 2012
RTM
LDR
-
The MANIFEST files (.manifest) and the MUM files (.mum) that are installed for each environment are listed separately in the «Additional file information for Windows 8 and for Windows Server 2012» section. MUM and MANIFEST files, and the associated security catalog (.cat) files, are extremely important to maintain the state of the updated components. The security catalog files, for which the attributes are not listed, are signed with a Microsoft digital signature.
For all supported x86-based versions of Windows 8
|
File name |
File version |
File size |
Date |
Time |
Platform |
|---|---|---|---|---|---|
|
Psxdll.dll |
6.2.9200.20657 |
289,280 |
09-Mar-2013 |
04:24 |
x86 |
|
Psxdllsvr.dll |
6.2.9200.20657 |
339,456 |
09-Mar-2013 |
04:24 |
x86 |
|
Psxss.exe |
6.2.9200.20657 |
650,240 |
09-Mar-2013 |
04:25 |
x86 |
|
Sua-ppdlic.xrm-ms |
Not Applicable |
2,873 |
09-Mar-2013 |
07:43 |
Not Applicable |
For all supported x64-based versions of Windows 8 and of Windows Server 2012
|
File name |
File version |
File size |
Date |
Time |
Platform |
|---|---|---|---|---|---|
|
Psxdll.dll |
6.2.9200.20657 |
315,904 |
09-Mar-2013 |
04:59 |
x64 |
|
Psxdllsvr.dll |
6.2.9200.20657 |
364,032 |
09-Mar-2013 |
04:59 |
x64 |
|
Psxss.exe |
6.2.9200.20657 |
837,120 |
09-Mar-2013 |
05:00 |
x64 |
|
Sua-ppdlic.xrm-ms |
Not Applicable |
2,873 |
10-Mar-2013 |
01:19 |
Not Applicable |
|
Psxdll.dll |
6.2.9200.20657 |
305,152 |
09-Mar-2013 |
04:24 |
x86 |
|
Psxdllsvr.dll |
6.2.9200.20657 |
354,304 |
09-Mar-2013 |
04:24 |
x86 |
Status
Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the «Applies to» section.
More Information
For more information about software update terminology, click the following article number to view the article in the Microsoft Knowledge Base:
824684Description of the standard terminology that is used to describe Microsoft software updates
Additional file information for Windows 7 and for Windows Server 2008 R2
Additional files for all supported x86-based versions of Windows 7
|
File name |
X86_d1d3e2cfd1573a5086cbc1ae0e34227d_31bf3856ad364e35_6.1.7601.22195_none_d6235662a99095b7.manifest |
|
File version |
Not applicable |
|
File size |
707 |
|
Date (UTC) |
18-Dec-2012 |
|
Time (UTC) |
06:33 |
|
Platform |
Not applicable |
|
File name |
X86_subsystem-for-unix-based-applications_31bf3856ad364e35_6.1.7601.22195_none_7623bf20678f756b.manifest |
|
File version |
Not applicable |
|
File size |
62,446 |
|
Date (UTC) |
18-Dec-2012 |
|
Time (UTC) |
06:36 |
|
Platform |
Not applicable |
Additional files for all supported x64-based versions of Windows 7 and of Windows Server 2008 R2
|
File name |
Amd64_2fb9030afc4f5a84d5c70e7814b63899_31bf3856ad364e35_6.1.7601.22195_none_bd77bdfff55d7104.manifest |
|
File version |
Not applicable |
|
File size |
716 |
|
Date (UTC) |
18-Dec-2012 |
|
Time (UTC) |
06:33 |
|
Platform |
Not applicable |
|
File name |
Amd64_ee855c5f7f3358d37718528ea64d446f_31bf3856ad364e35_6.1.7601.22195_none_853cef94ff17f9a6.manifest |
|
File version |
Not applicable |
|
File size |
716 |
|
Date (UTC) |
18-Dec-2012 |
|
Time (UTC) |
06:33 |
|
Platform |
Not applicable |
|
File name |
Amd64_eeab6e1f12351a34357a45d41ea85445_31bf3856ad364e35_6.1.7601.22195_none_3feb26a91c44d31e.manifest |
|
File version |
Not applicable |
|
File size |
1,064 |
|
Date (UTC) |
18-Dec-2012 |
|
Time (UTC) |
06:33 |
|
Platform |
Not applicable |
|
File name |
Amd64_subsystem-for-unix-..d-applications-core_31bf3856ad364e35_6.1.7601.22195_none_52b77cb1d0692a3f.manifest |
|
File version |
Not applicable |
|
File size |
58,151 |
|
Date (UTC) |
18-Dec-2012 |
|
Time (UTC) |
06:39 |
|
Platform |
Not applicable |
|
File name |
Amd64_subsystem-for-unix-based-applications_31bf3856ad364e35_6.1.7601.22195_none_d2425aa41fece6a1.manifest |
|
File version |
Not applicable |
|
File size |
63,787 |
|
Date (UTC) |
18-Dec-2012 |
|
Time (UTC) |
06:40 |
|
Platform |
Not applicable |
|
File name |
Wow64_subsystem-for-unix-..d-applications-core_31bf3856ad364e35_6.1.7601.22195_none_5d0c270404c9ec3a.manifest |
|
File version |
Not applicable |
|
File size |
42,861 |
|
Date (UTC) |
18-Dec-2012 |
|
Time (UTC) |
06:39 |
|
Platform |
Not applicable |
|
File name |
Wow64_subsystem-for-unix-based-applications_31bf3856ad364e35_6.1.7601.22195_none_dc9704f6544da89c.manifest |
|
File version |
Not applicable |
|
File size |
42,787 |
|
Date (UTC) |
18-Dec-2012 |
|
Time (UTC) |
06:39 |
|
Platform |
Not applicable |
Additional files for all supported IA-64-based versions of Windows Server 2008 R2
|
File name |
Ia64_7604db672cbb1af03eb08856158462fa_31bf3856ad364e35_6.1.7601.22195_none_a88f90d733ea8a5e.manifest |
|
File version |
Not applicable |
|
File size |
1,062 |
|
Date (UTC) |
18-Dec-2012 |
|
Time (UTC) |
06:33 |
|
Platform |
Not applicable |
|
File name |
Ia64_subsystem-for-unix-based-applications_31bf3856ad364e35_6.1.7601.22195_none_76256316678d7e67.manifest |
|
File version |
Not applicable |
|
File size |
63,784 |
|
Date (UTC) |
18-Dec-2012 |
|
Time (UTC) |
06:33 |
|
Platform |
Not applicable |
|
File name |
Wow64_subsystem-for-unix-based-applications_31bf3856ad364e35_6.1.7601.22195_none_dc9704f6544da89c.manifest |
|
File version |
Not applicable |
|
File size |
41,411 |
|
Date (UTC) |
16-Dec-2012 |
|
Time (UTC) |
18:54 |
|
Platform |
Not applicable |
Additional file information for Windows 8 and for Windows Server 2012
Additional files for all supported x86-based versions of Windows 8
|
File name |
Update.mum |
|
File version |
Not Applicable |
|
File size |
1,808 |
|
Date (UTC) |
11-Mar-2013 |
|
Time (UTC) |
08:46 |
|
Platform |
Not Applicable |
|
File name |
X86_abc6db3707e75a09460f94e1d26eafff_31bf3856ad364e35_6.2.9200.20657_none_02b4f29ac0374f57.manifest |
|
File version |
Not Applicable |
|
File size |
707 |
|
Date (UTC) |
11-Mar-2013 |
|
Time (UTC) |
08:46 |
|
Platform |
Not Applicable |
|
File name |
X86_subsystem-for-unix-based-applications_31bf3856ad364e35_6.2.9200.20657_none_714074dfda58f2e4.manifest |
|
File version |
Not Applicable |
|
File size |
65,697 |
|
Date (UTC) |
11-Mar-2013 |
|
Time (UTC) |
08:46 |
|
Platform |
Not Applicable |
Additional files for all supported x64-based versions of Windows 8 and of Windows Server 2012
|
File name |
Amd64_9a8f20613198143a7d8884742138d897_31bf3856ad364e35_6.2.9200.20657_none_5262302ca9ad9685.manifest |
|
File version |
Not Applicable |
|
File size |
1,064 |
|
Date (UTC) |
11-Mar-2013 |
|
Time (UTC) |
08:47 |
|
Platform |
Not Applicable |
|
File name |
Amd64_subsystem-for-unix-based-applications_31bf3856ad364e35_6.2.9200.20657_none_cd5f106392b6641a.manifest |
|
File version |
Not Applicable |
|
File size |
66,813 |
|
Date (UTC) |
11-Mar-2013 |
|
Time (UTC) |
08:47 |
|
Platform |
Not Applicable |
|
File name |
Update.mum |
|
File version |
Not Applicable |
|
File size |
1,818 |
|
Date (UTC) |
11-Mar-2013 |
|
Time (UTC) |
08:47 |
|
Platform |
Not Applicable |
|
File name |
Wow64_subsystem-for-unix-based-applications_31bf3856ad364e35_6.2.9200.20657_none_d7b3bab5c7172615.manifest |
|
File version |
Not Applicable |
|
File size |
41,529 |
|
Date (UTC) |
11-Mar-2013 |
|
Time (UTC) |
08:47 |
|
Platform |
Not Applicable |
Need more help?
Want more options?
Explore subscription benefits, browse training courses, learn how to secure your device, and more.
Communities help you ask and answer questions, give feedback, and hear from experts with rich knowledge.
I’m using Ubuntu 14.04. Recently, when I login via SSH with my user with sudo privileges, every command I run results in a “Cannot allocate memory” error. Here are a few I tried at my console
myuser@mymachine:~$ whoami
-bash: fork: Cannot allocate memory
myuser@mymachine:~$ uname -a
-bash: fork: Cannot allocate memory
Even if I try sudo reboot now I get the above error, so I don’t know what else I can try to unlock my instance. The host is DigitalOcean if that matters.
Edit: Per the answer/suggestion given here is the output of «free»
myuser@mymachine:~$ free
-bash: fork: Cannot allocate memory
Chai T. Rex
5,1171 gold badge24 silver badges47 bronze badges
asked Nov 3, 2016 at 20:01
0
Solution
As it says in the error messages, your machine has run out of memory. This can be for a number of reasons, but basically, something is eating up all of your memory and not leaving any left for even basic command usage.
I would suggest that you reboot your droplet (just go to your client control panel and select «Reboot»), ssh in and then run top or htop. Keep an eye on the memory usage and see what process is using up all the memory. From there, try either
- Killing/Removing the faulty program/process
WARNING: PLEASE do your research on if the process is an essential system process, first! If a system process is causing memory issues, don’t just kill it, do research on it and for specific ways to deal with it.
- Changing configuration for that program/process so that it doesn’t eat up all of your memory.
Suggestions for preventing the issue from happening again
- Something good to do is to add swap memory, as it allocates more memory if you’re running out.
- Whenever you install programs, make sure you configure them correctly so that they don’t perform in unintended ways (like eating up memory)
- After each time you add a package or basically anything new is configured, check with
htoportopto see how much memory you’re using up with the current programs. If you notice that you’re using almost all of it, try and clear some out by going through and removing unnecessary programs/processes. - If there is anything that’s being auto-started (besides system processes, of course!) that you don’t recognize or want to be auto-started, remove it! But always do your research on what a process is before killing/deleting it, as it could be essential for bootup procedures or system functions, etc.
answered Nov 3, 2016 at 20:55
TheOddTheOdd
2,9521 gold badge20 silver badges41 bronze badges
0
In completion to the accepted answer there is one additional thing to consider: Your system may run out of file handles or even socket buffers and still have lots of memory whilst giving the same error. This is especially true if the shared hosting imposes limits of such nature. On OpenVZ systems, watch the contents of
# cat /proc/user_beancounters
This will give you in the rightmost column the first overruns. If this is true, either move to a larger hosting package or hunt down the most likely culprit: the mysql or mariadb database which may, in presence of a defective PHP app, leak file handles to the hundreds per second.
This may also happen if your webserver has ssh open to the internet and accepts username / password logins: even if you have fail2ban running, you may have attracted a distributed dictionary break in attempt which also consumes a lot of resources.
answered Feb 27, 2019 at 15:53
aquaherdaquaherd
6,1401 gold badge28 silver badges39 bronze badges
Follow the following steps:
- sudo apt install htop
- sudo htop
- click F6 to sort and select PERCENT_MEM -> Enter
- Select the programs that you do not need but are eating most of the memory ( up and down arrow can be used)
- F9 and SIGKILL
answered Feb 20, 2022 at 20:42
2
Symptoms
error=12, Cannot allocate memory (Linux)
com.atlassian.bitbucket.exception.ServerException: An error occurred while executing an external process: java.io.IOException: error=12, Cannot allocate memory
error=12,Not enough space (Solaris)
com.atlassian.bitbucket.exception.ServerException: An error occurred while executing an external process: error=12, Not enough space
Cause
If you received error=12, Cannot allocate memory or error=12, Not enough space, this means your system ran out of memory or swap space when Java tried to fork a process.
The problem is inherent with the way Java allocates memory when executing processes. When Java executes a process, it must fork() then exec(). Forking creates a child process by duplicating the current process. By duplicating the current process, the new child process will request approximately the same amount of memory as its parent process, essentially doubling the memory required. However, this does not mean all the memory allocated will be used, as exec() is immediately called to execute the different code within the child process, freeing up this memory. As an example, when Bitbucket Server tries to locate git, the Bitbucket Server JVM process must be forked, approximately doubling the memory required by Bitbucket Server.
Note that this issue is made worse by hosting multiple webapps in the same Tomcat container as Bitbucket Server (which is not supported), because more memory is used by the Java process.
Please see Forking JVM for a more detailed explanation.
Resolution
If you are hosting multiple products in the same Tomcat container as Bitbucket Server, move Bitbucket Server to its own Tomcat container.
For Linux, this can be resolved by enabling over-committing memory.
For Solaris, we recommend increasing your swap space. How much swap space do you need? This will also depend on the other applications running on the same machine. We recommend allocating at least swap equal to 4 x JVM_MAXIMUM_MEMORY, or 2 x PHYSICAL RAM, whichever is larger. The JVM_MAXIMUM_MEMORY is set in your <Bitbucket Server installation directory>/bin/setenv.sh. You can increase your swap space if you are still running out of memory.
setenv and environment variable changes in Bitbucket Server 5.0+
Starting with Bitbucket Server 5.0, setenv.sh and setenv.bat have been removed. The options that were set in this file can now be set via environment variables. Where to set the environment variable depends on which Operating System you’re running on.
Linux
When using the atlbitbucket service on Linux, the environment variables are ignored. You must set the parameters in _start-webapp.sh (or start-bitbucket.sh). These values will be read when the service starts.
As an example, to set JVM_SUPPORT_RECOMMENDED_ARGS, you would add this line to the file:
Example
JVM_SUPPORT_RECOMMENDED_ARGS=-XX:+HeapDumpOnOutOfMemoryError
Windows
Set the parameter as an environment variable for the user running Bitbucket Server. For example, if you want to set JVM_SUPPORT_RECOMMENDED_ARGS, create it as an environment variable and assign the appropriate value to it. When Bitbucket Server starts using the startup scripts or service, it will pick up and apply this value.
