How to decrease virtual size of a process after cleaning all containers and using malloc_trim (0)?


 
Thread Tools Search this Thread
Top Forums Programming How to decrease virtual size of a process after cleaning all containers and using malloc_trim (0)?
# 1  
Old 03-11-2015
How to decrease virtual size of a process after cleaning all containers and using malloc_trim (0)?

Hello all
i have simple server running on linux redhat 6.1
it is build with c++
in the server i have huge std vector that holds pointers to cache objects
those cache objects holds allot of data from the DB
any way ...
in some point in time there is simple API that suppose to clean the vector
i do simple iteration over the std vector and delete the object pointers and in the end i also clean() the vector
and after all of this i execute : malloc_trim (0) that returns 1
the problem is that the virtual size of a process never decrease
BUT only the resident size do decrease fine .
the big problem when i like to load the cache again , the virtual size of a process get doubled .

how do i decrease virtual size of a process in c++/c ?
thanks
# 2  
Old 03-11-2015
Quote:
Originally Posted by umen
...

how do i decrease virtual size of a process in c++/c ?
thanks
You basically need to explicitly control all memory allocation, using library calls like mmap() and munmap().

As you've found, malloc_trim() doesn't really work, because any one malloc()'d bit of memory in the wrong location in the heap will wind up pinning the entire heap anyway. That's because of the way the brk()/sbrk() calls underlying malloc()/free() work in managing the heap - the standard implementation heap of memory using brk()/sbrk() has to be a single contiguous chunk of memory that has a fixed starting point. If there is any memory in use that's deep into the allocated heap space, all the memory up to and including that in use memory can't be returned to the OS.

If this is for work, instead of spending time and money trying to solve this problem by writing what will probably be a lot of buggy code that doesn't really solve anything, just buy more RAM for you server.
# 3  
Old 03-12-2015
Thanks for your replay
this is very problematic for me , as i can't buy more RAM
can it be i have some memory leek ?
Although the resident size do decrease fine ...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. AIX

[ASK] decrease/shrink the size of filesystem

Hello, I would like to reduce the size of filesystem online. We can do online for increase without any problem. So any risk can be occurred with the decrease? This is not an issue, just a discussion for decrease/shrink space with chfs command. My AIX system is version 6.1 and the filesystem... (2 Replies)
Discussion started by: Phat
2 Replies

2. UNIX for Dummies Questions & Answers

Decrease buffer size

Hi, I am using the below command to get the output in a file called "Logs.txt" tail -f filename | egrep -i "cpu | hung " >> Logs.txt The problem is the Logs.txt file gets updated only after the buffer is 8Kb, but i want to update the file immediately and not wait for the buffer to get 8kb. Is... (8 Replies)
Discussion started by: @bhi
8 Replies

3. Fedora

How to increase/Decrease Local Virtual consoles?

I m tring to figure out the option where i can increase/Decrease the count for local virtual consoles(vtys). I can able to take upto 6 vtys using (left alt+(F1-F6)) But is there any way i can increase the count ? One more query even though i can only take tty upto tty6 why there are tty... (2 Replies)
Discussion started by: pinga123
2 Replies

4. AIX

Why using "%" of Paging size increases & how to decrease this percentage?

Hi I have found a problem on my AIX 5.1 server. day by day the paging size is increasing,what is the reason behind it and if percentage is at 100 what will happen. Oracle 9i is running on my server. PAGING SPACE size,mb 5632 % used 14.6 % free 85.3 How can i decrease the using... (6 Replies)
Discussion started by: dearsumon
6 Replies

5. UNIX for Advanced & Expert Users

Process self-exec and virtual memory size

Hello all, To do a self-exec or self-restart of a process when it crosses the threshold memory limit, I use the value of virtual memory size field from /proc/$pid/stat file and do a self-exec. According to man 5 proc vsize %lu Virtual memory size in bytes. I just want to... (2 Replies)
Discussion started by: matrixmadhan
2 Replies

6. Programming

Find Virtual address space size for process

Hi, I am looking to work on unix systems which include (hp-ux, ibm aix, solaris and linux). I want to get the total virtual address space of a process, the used virtual memory i am able to get without any problem. I have tried using getrlimit and getrlimit64, but that gives only ... (4 Replies)
Discussion started by: uiqbal
4 Replies

7. Shell Programming and Scripting

How to decrease the font size in Mailx

Hi all, I am using echo "$EMAILMESSAGE" | mailx -s "$SUBJECT" -b $CC "$TO" I am receiving the mail but seems to big in font size. Is there any option mailx to decrease the size of the mail generated. Thanks, (1 Reply)
Discussion started by: shellscripter
1 Replies

8. UNIX for Dummies Questions & Answers

how to Decrease priority of a particular process in time of process creation

how to decrease priority of a particular process in time of process creation... and also how to decrease priority of a particular process after process creation.. can any one please help me out... (2 Replies)
Discussion started by: Ramkum
2 Replies

9. UNIX for Dummies Questions & Answers

how can i get The total size of the process in virtual memory om GB or MB

Hello all im using the ps -ef "args vsz" | some.exe but the result is in kb , is there some kind of way or flag ( didnt found in the ps man ) to convert me this data to GB or MG in human readable format ? Thanks (1 Reply)
Discussion started by: umen
1 Replies

10. Programming

Will exe file size decrease while using inline function

using namespace std; void g(); class A { public : A() { g();g();g(); cout << "Constructor of A"<< endl ;} }; inline void g(){ cout << "vijay" <<endl; } int main() { A a; } when i use inline i get size 303488 Aug 31 12:05 a.out* when not using inline i get size 303572 Aug 31... (1 Reply)
Discussion started by: vijaysabari
1 Replies
Login or Register to Ask a Question