Operating System - HP-UX
1832183 Members
2868 Online
110038 Solutions
New Discussion

Re: memory fragmentation, does it exist?

 
cart
Advisor

memory fragmentation, does it exist?

Hi,

Does memory fragmentation make sence on HPUX11i?
I mean: is it possible that a process request, lets say, 1MB and there is not a 1MB contiguous region in memory, so the request fails?
I believe that the OS works with memory page (4kb pages) and it works only with pages, moving them as needed from swap to physical memory....
Am I wrong?
Does a memory region need to be a contiguous set of pages?

Thanks for your help!

Sundance
14 REPLIES 14
Mark Grant
Honored Contributor

Re: memory fragmentation, does it exist?

Memory fragmentation can occur quite easily if you want. Just allocate loads of smallish blocks of RAM and then randomly de-allocate them.

As far as I remember, the OS allocates blocks of contiguous RAM in pages from a free list and if you request a GB and there isn't that much, it will fail. I might be wrong though. However, even if it is true, then the solution is so get your RAM in smaller chunks.

You might find the man page for malloc of interest because there is some fine tuning you can do.

"man 3C malloc"
Never preceed any demonstration with anything more predictive than "watch this"
G. Vrijhoeven
Honored Contributor

Re: memory fragmentation, does it exist?

Hi Sundance,

You might want to read up on memory management:

/usr/share/doc/mem_mgt.txt


Hope this will help,

Gideon
Jim Butler
Valued Contributor

Re: memory fragmentation, does it exist?

maxdsiz enables the upper limit for the max data segment size

Other than that tidbit - I'll defer to the experts...
Man The Bilge Pumps!
Jim Butler
Valued Contributor

Re: memory fragmentation, does it exist?

maxdsiz (Kernel Parameter) enables the upper limit for the max data segment size

Other than that tidbit - I'll defer to the experts...
Man The Bilge Pumps!
Hein van den Heuvel
Honored Contributor

Re: memory fragmentation, does it exist?


Memory fragmentation in general plays no role, because as you indicate the VM subsystem just gathers and scatters those 4kb pages.

However... an image can HINT to the VM subsystem to grab larger chuns and address those with few pointers. This will make memory management, and more importantly run time, more efficient. Some (oracle!) applications can gain back 10% CPU time with hints of 4MB pages. For those hints to be honoerd, you'd need coniguous pages.

Check out the pi and pd arguments for the chatr command!

hth,
Hein.
Tim Sanko
Trusted Contributor

Re: memory fragmentation, does it exist?

Sunny boy(girl),

If I were to say that it can play no part in affecting perfirmance I would be lying.

Forced context switching seems to be horribly
high on a server within 100 MB of swapping.

We upgraded to Oracle 8.1.7 and the resulting memory pressure increased. We would be with 4k of swapping on a 16 way V2600. The box would crawl to a stop not to swap, we were faster when the box did swap.

So we added 8 GB ram. Now we fly again.

We may be a unique situation, but I believe you should avoid being close to swapping if you can...

I am using 8.5 GB ram nost often maxing at about 13 GB RAM used...

Tim
cart
Advisor

Re: memory fragmentation, does it exist?

Thanks for your replys (especially Hein because he says I'm right!!).

I didn't find the usr/share/doc/mem_mgt.txt on my system, but found a document in docs.hp.com

Our system is not swapping memory. We don't have performance issue either. But the used memory increase. We think of a memory leak in the application. The software provider says it is because of memory fragmentation...

Sundance (boy)
Elmar P. Kolkman
Honored Contributor

Re: memory fragmentation, does it exist?

Sundance,

Here is Gideon's document...
Every problem has at least one solution. Only some solutions are harder to find.
Massimo Bianchi
Honored Contributor

Re: memory fragmentation, does it exist?

If you want to keep memory under control
, and check which process is stealing the memory, you have many ways:

- install (and pay) mwa, and trck down memory usage on a per process basis

- create (for free) a cron script that lists the memory for each proc with the command "
UNIX95= ps -e -o ruser,vsz,pid,args |sort -rnk2"

Examine the result, in any way you obtained it, and filnd the guilty!

HTH,
Massimo
cart
Advisor

Re: memory fragmentation, does it exist?

Massimo,

You're right! We did the ps stuff and found out the process grow from 180MB to 250MB. And once we let them eat all swap until we were out of memory!
SO we know which process is growing. But we can tell why.

Could there be such thing as virtual memory fragmentation?
As Mark G said, if the program malloc/free inconsistant bloc (bigger and bigger blocs), we could have fragmentation. But does it impact swap/RAM usage? I'd say no, it is only in the virtual memory

Is there a way to check how much space there is in the data memory segment?
Or do tools like Glance report excactly what is being used?

Can we think about something like: memory pages are not used efficiently (only 3kB used in the 4 KB page) ?

I'm going to read the HP-UX Memory Management White Paper. I let you know if I understand anything better!!

Sundance
Massimo Bianchi
Honored Contributor

Re: memory fragmentation, does it exist?

Glad to be of help.

If you know the process, notify the Software House. Memory fragmentation should not be responsible, since each program request memory, but not the exact bucket.

It's the O.S. that is responsible for that.

Try to tarck down an entire session, using tusc, and see if for every malloc there is a mfree... or better, have the software support check it for you, since you have not the code.


I do not think that glance can descend in the memory, but it is installable for 60days for free, so a try won't hurt.

Massimo
Massimo Bianchi
Honored Contributor

Re: memory fragmentation, does it exist?

Another shot: there are situation in which even the O.S. has some bugs...


Check if you have the latest patches using the word leak :)

Massimo



Hein van den Heuvel
Honored Contributor

Re: memory fragmentation, does it exist?


You are going to like me Sundance kid...
I'm going to say that you are right again.

This is very unlikely to be a Unix bug, swapping problem or any to that stuff. There is no indication that the system is not simply doing what it is told. There are multiple memeory managers. There is the VM/page manage in the os at a global level. But within each process there is the malloc/free (or alternatives) process local memory manager which requests large chunks of VM from the OS (check: man brk, man sbrk) and then parcels out smaller pieces.

> Could there be such thing as virtual memory fragmentation?

Yes. It is often called 'laddering'. It is often attempted to be solved through 'binary buddy' system. Here is a sample scenario:
malloc 5kb(1) temp, 5kb(2) temp, release 5kb(1), malloc 3kb(3) permanent. That 3Kb might fit the first 5kb hole leaving 2kb unused. Repeat often enough and you'll be inefficient, but it will not be deadly.
For it to become deadly it needs to be combined with an optimization algoritme in the process vm manager (like a size based look-aside list), and very unlucky allocation patterns. Notably where the application hangs on to small morcels of malloced data, with large holes between them.


Or... much more simple... the application 'forgets' about malloced data, never freeing it, but never re-using it either!

Time to go back to the software vendor or perhaps an inhouse applciation development group. They would then likely use tools like 'Electric Fence' to locate the problem.
(Google for : +malloc +leak +tool)

> But does it impact swap/RAM usage? I'd say no, it is only in the virtual memory

It is VM, but you touched it, dirtied it and thus the system is obliged to remember it! It does nto know you might not come back for it. And in fact you might be coming back for 10 bytes every 4kb. If you don't come back, it can just swap out and it will not hurt too much as long as you have swap space. But it may trigger ugly memory reclaim algoritmes and may the system in general.

Hein.
John Carr_2
Honored Contributor

Re: memory fragmentation, does it exist?

Hi

you can checkout the memory as already mentioned with mwa. what was omitted is you can have a 30 day trial for FREE checkout the download area.

John.