How to change allocated memory for a process?


 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers How to change allocated memory for a process?
# 1  
Old 04-18-2019
How to change allocated memory for a process?

Hello,
I am running ubuntu 14.04 in a server with 32GB ram.
Due to receiving "high load" errors during ssh connection, I took a look at what's happening from command line. I detected that 20GB of total memory was allocated to a program.
Below you can see some initial part of installation script. As I believed this issue is not classified as shell scripting issue, I opened the thread under "general & beginners" field. Hope I am right.

Code:
#!/bin/sh
chmod 777 *.*
chmod 777 *
echo 2062780 > /proc/sys/kernel/threads-max
if ! cat /etc/sysctl.conf | grep -v grep | grep -c 1677721600 > /dev/null; then
echo 'net.core.wmem_max= 1677721600' >> /etc/sysctl.conf
echo 'net.core.rmem_max= 1677721600' >> /etc/sysctl.conf
echo 'net.ipv4.tcp_rmem= 1024000 8738000 1677721600' >> /etc/sysctl.conf
echo 'net.ipv4.tcp_wmem= 1024000 8738000 1677721600' >> /etc/sysctl.conf
echo 'net.ipv4.udp_mem =1024000 8738000 1677721600' >> /etc/sysctl.conf
echo 'net.ipv4.tcp_window_scaling = 1' >> /etc/sysctl.conf
echo 'net.ipv4.tcp_timestamps = 1' >> /etc/sysctl.conf
echo 'net.ipv4.tcp_sack = 1' >> /etc/sysctl.conf
echo 'net.ipv4.tcp_no_metrics_save = 1' >> /etc/sysctl.conf
echo 'net.core.netdev_max_backlog = 5000' >> /etc/sysctl.conf
echo 'net.ipv4.route.flush=1' >> /etc/sysctl.conf
echo 'fs.file-max=65536' >> /etc/sysctl.conf
sysctl -p
fi
#...
#..
#.
#the rest of the code is related to installation of the application

Do you think that when I change "2062780" to half of the value, could it be the solution and what about other values? I believe 1031390 memory is enough for this application as it was not much busy.

free -m
Code:
             total       used       free     shared    buffers     cached
Mem:         31882      30995        887          8        263      19988
-/+ buffers/cache:      10742      21139
Swap:         4093          0       4093

cat /proc/meminfo
Code:
MemTotal:       32648164 kB
MemFree:          267172 kB
MemAvailable:   21145252 kB
Buffers:          270424 kB
Cached:         20632720 kB
SwapCached:            0 kB
Active:         14189768 kB
Inactive:       16692520 kB
Active(anon):    8927760 kB
Inactive(anon):  1063128 kB
Active(file):    5262008 kB
Inactive(file): 15629392 kB
Unevictable:        9548 kB
Mlocked:            9548 kB
SwapTotal:       4192248 kB
SwapFree:        4192248 kB
Dirty:           3240844 kB
Writeback:        178960 kB
AnonPages:       9969652 kB
Mapped:            67196 kB
Shmem:              8300 kB
Slab:             526704 kB
SReclaimable:     454312 kB
SUnreclaim:        72392 kB
KernelStack:       14784 kB
PageTables:        38632 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:    20516328 kB
Committed_AS:   11570060 kB
VmallocTotal:   34359738367 kB
VmallocUsed:           0 kB
VmallocChunk:          0 kB
HardwareCorrupted:     0 kB
AnonHugePages:   5294080 kB
ShmemHugePages:        0 kB
ShmemPmdMapped:        0 kB
HugePages_Total:       0
HugePages_Free:        0
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:       2048 kB
DirectMap4k:       14560 kB
DirectMap2M:     2772992 kB
DirectMap1G:    30408704 kB


My /etc/sysctl.conf file:
Code:
net.core.somaxconn = 65535
net.ipv4.route.flush=1
net.ipv4.tcp_no_metrics_save=1
net.ipv4.tcp_moderate_rcvbuf = 1
fs.file-max = 6815744
fs.aio-max-nr = 6815744
fs.nr_open = 6815744
net.ipv4.ip_local_port_range = 1024 65000
net.ipv4.tcp_sack = 1
net.ipv4.tcp_rmem = 10000000 10000000 10000000
net.ipv4.tcp_wmem = 10000000 10000000 10000000
net.ipv4.tcp_mem = 10000000 10000000 10000000
net.core.rmem_max = 524287
net.core.wmem_max = 524287
net.core.rmem_default = 524287
net.core.wmem_default = 524287
net.core.optmem_max = 524287
net.core.netdev_max_backlog = 300000
net.ipv4.tcp_max_syn_backlog = 300000
net.netfilter.nf_conntrack_max=1215196608
net.ipv4.tcp_window_scaling = 1
vm.max_map_count = 655300
net.ipv4.tcp_max_tw_buckets = 1440000
kernel.shmmax=134217728
kernel.shmall=134217728
net.core.wmem_max= 1677721600
net.core.rmem_max= 1677721600
net.ipv4.tcp_rmem= 1024000 8738000 1677721600
net.ipv4.tcp_wmem= 1024000 8738000 1677721600
net.ipv4.tcp_window_scaling = 1
net.ipv4.tcp_timestamps = 1
net.ipv4.tcp_sack = 1
net.ipv4.tcp_no_metrics_save = 1
net.core.netdev_max_backlog = 5000
net.ipv4.route.flush=1
fs.file-max=65536

I'd appreciate your comments.

Thank you
Boris

Last edited by baris35; 04-18-2019 at 04:09 PM.. Reason: extra info added
# 2  
Old 04-18-2019
The only 2062780 I see in your code snippet is being written to the kernel parameter "threads-max", the maximum allowed processes / threads on the system. What makes you think this has to do with memory allocation?
# 3  
Old 04-18-2019
Hello Rudic,
I expect to get rid of "high load" warning when I connect to server via ssh. I also read some other solutions regarding /etc/ssh/sshd_config in many boards but those explanations did not solve the issue.
Assumption: As there is no allocated memory for other processes, it stucks. If other processes have more ram to use, system load will be lower. (Just an assumption)

Thanks
Boris
# 4  
Old 04-19-2019
Your swap consumption and "MemAvailable" indicate there's no memory shortage. Is that "high load" an ssh message? Does it mayhap refer to CPU load? What be the CPU load when you log in?
# 5  
Old 04-20-2019
Hello Rudic,
I am sorry for my delayed return. When I connect to ubuntu via ssh, it shows info about status, you know it.
At that moment, normally I could see system load as percent. As you said, there is no relation with ssh and system load.
First I thought there were some misconfigured parameters in sshd_config file but could not have found any clue causing this issue. I made some changes at running processes and it's okay so far.

Thank you for your time
Boris
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Red Hat

KVM/Qemu allocated memory not showing in guest

So we have a RHEL 7.6 workstation with 128 gigs of ram. The OS sees all the ram and 80 cors (40 HT) We have 1 guest with 8 CPUs and 32gigs of ram running RHEL 7.6 workstation as well. We are trying to create another guest with 64 CPUs and 80 gigs of ram. We setup the system using... (0 Replies)
Discussion started by: joeg1484
0 Replies

2. Solaris

[DOUBT] Memory high in idle process on Solaris 10 (Memory Utilization > 90%)

Hi Experts, Our servers running Solaris 10 with SAP Application. The memory utilization always >90%, but the process on SAP is too less even nothing. Why memory utilization on solaris always looks high? I have statement about memory on solaris, is this true: Memory in solaris is used for... (4 Replies)
Discussion started by: edydsuranta
4 Replies

3. Programming

Regarding the maximum memory allocated by malloc() function on HP-UX B11.11

In a 'C' program,when I am trying to allocate memory with the help of malloc () function, it is allocating the memory up to a certain limit for e.g. in my case, it is 670 MB (approx). malloc() returns NULL if I allocate more than this amount of memory.When I tried to allocate memory in chunks of... (1 Reply)
Discussion started by: vipinsachan
1 Replies

4. Linux

change the memory address of ld.linux-so in a dynamically linked process

hi, For some special reason , I'd like to control the memory address for the shared libraries in my dynamically linked process. And it is the "ld" which interpret the dynamically linked library, and in my system, the "ld-linux.so.2" is put at 0x00812000. Then I use "prelink -r" command to... (3 Replies)
Discussion started by: zerocool_08
3 Replies

5. UNIX for Dummies Questions & Answers

change the memory address of ld.linux-so in a dynamically linked process

hi, For some special reason , I'd like to control the memory address for the shared libraries in my dynamically linked process. And it is the "ld" which interpret the dynamically linked library, and in my system, the "ld-linux.so.2" is put at 0x00812000. Then I use "prelink -r" command to change... (0 Replies)
Discussion started by: zerocool_08
0 Replies

6. HP-UX

how to find size of memory allocated to a pointer?

Hi, Am new to HP UX , is there a way to find out the size of memory allocated to a pointer on hp ux? For example we can use the _msize() on windows to find the size of memory allocated to a pointer . #include <stdio.h> #include <malloc.h> void main() { void *buffer; ... (0 Replies)
Discussion started by: Wkdunreal
0 Replies

7. Programming

Why memory allocated through malloc should be freed ?

Actually for a process to run it needs text, stack , heap and data segments. All these find a place in the physical memory. Out of these 4 only heap does exist after the termination of the process that created it. I want to know the exact reason why this happens. Also why the other process need to... (20 Replies)
Discussion started by: karthiktceit
20 Replies

8. AIX

amount of memory allocated to large page

We just set up a system to use large pages. I want to know if there is a command to see how much of the memory is being used for large pages. For example if we have a system with 8GB of RAm assigned and it has been set to use 4GB for large pages is there a command to show that 4GB of the *GB is... (1 Reply)
Discussion started by: daveisme
1 Replies

9. UNIX for Advanced & Expert Users

process memory change in unix

Hello! I was wondering if I could trouble all your experts with a couple questions regarding checking memory usage changes during the run time in the specific program (process) under UNIX. 1. After the program starts running, is ps the best way to tell the total memory usage at the any time? ... (2 Replies)
Discussion started by: aginger
2 Replies

10. Solaris

Memory allocated

Hi, How to find out what is the maximum memory allocated to TOMCAT server in SunOS 5.8? The Tomcat server crashes down during peak times.... Regards (1 Reply)
Discussion started by: baanprog
1 Replies
Login or Register to Ask a Question