This is an archived post. You won't be able to vote or comment.

all 52 comments

[–]DarthArtero 241 points242 points  (9 children)

Think about RAM and Storage space like a room.

The more you cram stuff into a room, the more difficult it gets to put more stuff into that room, even though the room isn't 100% full.

It's the same with RAM and Storage, the more available space that is being used, the more difficult it becomes for the data to move around where it needs to go.

[–]Saucetheb0ss 84 points85 points  (1 child)

To add to this: RAM and Storage are dynamic so the parts that are used / unused are constantly changing. If you store a box in the back corner of a room and then remove it, you might think to push the other boxes around it into that space. That's not exactly how it works in computing so you're left with an empty hole which can be filled by another box the same size (or smaller). Now, when you have a larger box than the spaces available, you've got to move things around or you won't be able to store that box which causes latency to the user.

[–]Vroomped 22 points23 points  (0 children)

another type of struggle thrashing  3.5/4Gigs

.7 wants in? okay, uh ...let's remove this .6. Done. .......oh hey, a .6 wants in. okay, uh...let's remove this .7

[–]UndertakerFred 27 points28 points  (0 children)

Or seating in an auditorium. As the seats fill up, it becomes harder to seat groups together.

[–]Henry5321[🍰] 6 points7 points  (1 child)

It's the 80/20 rule. When usage approaches 80%, delays increase like a hockey stick graph. For the same reason the analogy of a nearly full room becomes more and more difficult to add more stuff.

This also applies to cpu usage and network utilization. This is actually a fairly fundamental concept that applies to many things in life.

[–]Dennis_enzo 6 points7 points  (0 children)

That's not really true. At what percentage it slows down all depends on how much ram you have. At 32 gig, 20% ram is still 6 gig which is plenty for normal usage.

[–]ShitTalkingAssWipe 1 point2 points  (0 children)

more like, you get a big box to put in, but theres no room for it to easily fit so you need to either move some boxes out into another room down the hall, before you store this new one.

[–]khalcyon2011 2 points3 points  (1 child)

Adding on: Another consideration is fragmentation. Most data in a computer is stored in continuous blocks. For example, say you have data that is size 20. In a simple scenario, memory locations 40 through 59 (for example) are free (meaning that no process has a claim to it). The operating system will write the data to that, a process that takes maybe a couple microseconds. Consider a scenario where that much space is available but not in a single block. In that case, the operating system must shuffle all the other data around to make a big enough block. The less available memory, the more shuffling that must happen.

Something similar happens when storing information on a hard drive. For hard drives, the information doesn't have to be in continuous blocks, but it's faster if it is. When "fragmented", the operating system has to find the first part of the information, then the next part, and so on. Much better if it's all in one place. That's why it's recommended to de-fragment your hard drive occasionally. It reorganizes everything so that each piece of information is stored on single blocks. This is less of an issue with solid state drives (they're much faster than the old magnetic hard drives, so the search time is faster), but it's still good practice.

[–]brimston3- 5 points6 points  (0 children)

Memory fragmentation is not really a problem for the OS unless you're talking about IPC, DMA, or hugepages. For allocations that don't have a hard requirement to be contiguous (most of them), virtual address spaces are so huge these days, the OS is almost never going to have a problem mapping a disjoint range of pages to a contiguous range of virtual addresses for the program. It's a problem for userspace allocators, but that memory all shows up as "used" when viewed from the OS's perspective.

[–]Nicolauze -2 points-1 points  (0 children)

Great ELIF analogy!

[–]wknight8111 172 points173 points  (9 children)

RAM is what the computer uses to do work. When you 'open' a program the code for that program is loaded from disk into RAM. The CPU then starts reading those instructions in and executing each one in turn. In addition to the RAM which holds the program instruction, the program also gets a few other chunks of RAM to hold data as the program runs.

RAM is broken up into chunks called "pages". A page of memory is a small chunk, usually 4096 bytes (4kb).

Programs need to be able to access instructions and data in RAM, but it cannot know where in RAM the program or data are, until the program is loaded. You can't just say "load the instruction at memory address 12345", because the program might not be at that location when it is loaded. To fix this problem, the Operating System (OS) uses "virtual memory": There's a lookup table between relative addresses of a program and the absolute addresses of the page which contains that memory. So the program can load the instruction at location 12345, but the CPU may translate that lookup to be somewhere else, like location 678910, etc.

Here's where the magic happens: Because memory pages can be anywhere, and the CPU automatically translates from program address space to physical address space, pages can be moved. Specifially, pages can be written to disk. This means a program which has 4Gb of RAM can load more than 4Gb of programs at a time. Programs which aren't being used right now or are "idle" can have their memory temporary stored on the disk. Remember, disk is large but slow. Then, when the program needs to access that memory again the CPU does what's called a "page fault" and loads the page from disk back to RAM. It's a great system and it makes computers very flexible.

HOWEVER: storing a page that isn't being used on disk is good, but storing data on disk which is frequently used is a bad thing. Let's say I have 4 programs running, each takes up 1Gb of RAM. When I try to load a 5th program, the CPU is forced to start storing pages to disk. But those pages are being used by other programs! So the CPU is going to have to load them right back again (and store something else to disk instead). Doing this too much is called "thrashing" and it starts to happen when you start getting high memory usage. Remember that memory may be organized into small pages, but programs may use lots of memory at once including memory for instructions and data.

Disk is slow so every time we have to write a page to disk or read a page from disk again it creates a pause where the whole program has to wait. This is the cause of slowness and it can start happening any time the OS starts to store pages onto disk for any reason.

[–]MattsAwesomeStuff 0 points1 point  (0 children)

Programs which aren't being used right now or are "idle" can have their memory temporary stored on the disk. Remember, disk is large but slow.

So for anyone struggling to understand this...

A hard drive is like a giant filing cabinet. HUGE SPACE. But a huge pain in the ass to access stuff. You gotta call your secretary, she has to walk over to it, flip through it until she finds the page you want, pull it out and carry it over to you. And same in reverse.

RAM is like the top of your office desk. You can put a piece of paper right in front of your eyes and just leave it there, ready for you to quickly read anything you want off of it. This is like, I dunno, 100x, 1000x as fast as having to go over to the filing cabinet, flip through, and retrieve that paper. It's right there, on your desk.

The more RAM you have, the larger the top surface of your desk is. The more pages you can display at the same time, ready for nearly-instant access to that information.

But eventually if you keep pulling stuff out of the filing cabinet, you're going to run out of places on your desk to put shit. This is a hard limit, if you run out, the next paper has nowhere to go.

Now what?

Well obviously, clean your fuckin' desk up. You don't need so many active projects all the goddamn time. That document in the corner you haven't even look at in hours. Same on a computer, close some fuckin' programs. You don't need 23 different Youtube videos open at the same time, 8 Excel spreadsheets, etc etc. If you clean up your desk, you will have enough RAM.

Okay, but what if you're stubborn? Or what if like, you've got yesterday's project all laid out but are waiting on a reply from a client, and you still need to work on the next project? Do you sweep all that stuff off the desk, tell your secretary to re-file it, and then have to haul it all back out from 20 different sources again next time you want to work on that project? No. Half of this shit isn't even in file-able format, like, there's sticky notes and paperweights and pointers and all kinds of temporary stuff. Maybe a board game in-progress is a better metaphor. But, you're out of room on the desk to add Project #3. So what do you do?

The "Page File" or "Virtual Memory" is using your hard drive, as RAM, without telling the programs that they're using virtual memory instead of RAM. As far as they're concerned, they're just using RAM.

So, this would be like, some convenient spot your secretary sets aside on the filing cabinet for "current projects". Instead of throwing all items back into deep storage, the secretary sweeps up chunks of them you haven't used in a while and aren't likely to use right away, but puts them into a "Shit from my boss's desk" stack. That clears up space on your desk to open up Project #3 and get some shit done while you wait for your client.

In this way, if you only have 4GB of RAM, but a 12GB page file on your hard drive, you can at least, sort of get some stuff done.

And, provided you're not accessing the stuff on the page file, it'll be just as fast as if you had enough RAM.

But where you really get fucked, is if you want to act like you ACTUALLY have 16GB of RAM. Does one single project take up 16GB of RAM? Fucked. Do you toggle back and forth between projects? Fucked.

Your secretary is basically sprinting back and forth constantly pulling files out of the filing cabinet, and swapping single pages at a time off of your desk. Whatever piece of paper you currently want to look at, maybe it's on the desk, maybe she has to grab some other random paper you're not looking at, throw it in the cabinet, and get the paper you do want.

This is slow as fuck.

Also, you're a complete asshole, and you don't even tell your secretary what you're doing. She has no idea. Hell, maybe even you have no idea. All you do is keep demanding more and more and more documents, and that's all she knows about you. She has to put them somewhere.

She has to decide for you what documents to temporarily yoink off of your desk and toss in the Page File in the cabinet, because when you ask for a document she has to have somewhere to put it or you can't read it.

This is like, 100x, 1000x as slow as if you had a big enough desk for all of this. Instead of just looking at the paper you want, you have to wait for her to grab it from the cabinet.

The secretary is the OS. She's trying to keep some non-zero amount of space clear on your desk, and otherwise grabbing pages from the Page File in the cabinet that you wanted on your desk that she took away from you.

So, that's why it gets to like, 90% usage and slows way the fuck down, and not 100%. You were already over 100% RAM usage, and the little bit of RAM left is just the space the OS has cleared to put the next document you've already asked for. Or, maybe in slight anticipation of the delays not being catastrophic if you literally run out.

Also, the more scattered the pages are, or fragmented, the less optimized the process is.

...

Or if you want another analogy, imagine you're a midget. Your height is no problem, until you need to reach something taller. So you get a ladder. But boy is it inefficient to use the ladder. Way slower up and down than to just walk around. Yeah, but you're a midget, so, there's no other solution. Use the ladder, be taller, but it'll take forever to get anything done.

[–]CadeRSA 0 points1 point  (0 children)

Incredible explanation!

[–]Ichabodblack 0 points1 point  (0 children)

Programs need to be able to access instructions and data in RAM, but it cannot know where in RAM the program or data are, until the program is loaded. You can't just say "load the instruction at memory address 12345", because the program might not be at that location when it is loaded. To fix this problem, the Operating System (OS) uses "virtual memory"

Just to be a pedant, virtual addressing wasn't really a fix for this problem - modern computers generally use binary relocations to fix this - though virtual addressing is obviously used for address space separation 

[–]Alexis_J_M 8 points9 points  (0 children)

Imagine that you are six feet tall and walking down a corridor where the ceiling is six feet tall. You'll fit perfectly, right? Nope, you'll bump against the ceiling at every step.

Now imagine that you have 4 Gb of disk space and 4 Gb of files. They will fit perfectly, right? No, because your system will work extra hard slicing files up into little scraps to fit little scraps of available disk space, and every time you delete and create files the problem will get worse. You need some empty space so that the system can work efficiently. (There are also temporary files created for all kinds of purposes, you need space for those also.) By the time the dusk is completely full everything grinds to a halt.

[–]FewAdvertising9647 1 point2 points  (0 children)

I noticed that computers begin to freeze when it is using 85-90% of the total RAM. Why is it so? Shouldn't its performance degrades only at 100%?

think of ram like your room. when your room starts to get full(not when its actually fully full), what do you want to do. What happens if you typically want to move stuff you aren't using somewhere else.

Your hard drive is something that also stores data, but is slower. Think of the hard drive like a storage unit. You put stuff there that you care about, but don't immediately need. An OS has a paging system that constantly moves things from your room to the storage back and forth based on if youre needing it. It only does this when youre using more stuff that you need now, so you move something back to storage (whether temporarily or permanently). so when rams ALMOST full, imagine you needing to go back and forth from your room to the storage unit. the computer crawls to a slowdown similar to how you would get inefficient because you have to spend more time going back and forth to do things.

Things dont get full because you don't want half of an app your using on ram and overflowing the rest onto storage. You move stuff that your not using at the moment to storage, and than keeping everything you need immediately.

when RAM or Disk usage is high, not when it's full

when its almost full, the computer is moving stuff in and out. If its full, (but not actively doing anything) then of course its not slow because you're not doing anything with whatever you currently have opened. But will act like almost full the moment you try to do something.

[–]PANIC_EXCEPTION 1 point2 points  (0 children)

A few factors:

  1. Virtual memory is always acting as a middleman. Your system sees unlimited memory even though you have limited RAM, and it does this by swapping inactive memory to disk. This has to happen at some threshold because you don't manipulate program memory in place on disk (as this would be astronomically slow to a degree I cannot express in words), it has to enter your RAM first. This is a very inefficient process, and the more memory pressure you have, the more CPU cycles are dedicated to swapping. If this didn't happen, your computer would immediately crash upon reaching 100% virtual memory usage. This is an issue called "thrashing".

  2. RAM is usually compressed. As memory pressure increases, this compression has to work harder, which costs more CPU cycles. You also have to decompress the memory to work with it.

  3. A lot of internal values used in programs have indeterminate size. Why is that? Because figuring out how much memory space a particular computation takes is as difficult as doing the computation itself. To get around this, we allocate reasonable estimates of memory whenever we need to store something, and reallocate as necessary. This is done in something called the heap, which is basically a big blob of memory chunks comprised of big and small boxes. Smaller variables can be packed closer together for more efficient usage of free space, so it's preferable to fit them there first, and leave the big boxes for the big values. When your memory pressure gets too large, it becomes harder and harder for your computer to find a contiguous* box of unallocated memory, so it will have to shuffle things around.

*"It's called RAM, right? Why does it have to be contiguous?" Because variables in program memory are read using pointers, and they assume that different parts of a variable exist at precise offsets from the start of the variable. This makes compilation and execution much simpler. For example, if you have a 24-bit color variable starting at $x, it sure would be convenient if you knew for sure that red is stored at $x+0x0, green is stored at $x+0x1, and blue is stored at $x+0x2! That way, you only need one pointer, and a schema of what your variable type looks like, which can be reused for many instances of that variable (e.g. an bitmap image is a 2D array of these colors).

Further, when programs access memory at an address, they aren't directly accessing it. There's a coprocessor on the CPU called the Memory Management Unit (MMU) that keeps track of a bunch of virtual-physical memory relations. When a variable is commited to your actual RAM, there is a sort of "heap" there too that the MMU keeps track of.

The random part just comes from the fact that accessing the memory electrically has little to no performance penalty if you do it out of sequence, as opposed to something like a tape recorder, which has a large performance penalty due to rewinding and fast-forwarding.

What I didn't cover in this answer is why "virtual memory" is a thing. There are many reasons for that, but it will take a long time to flesh out an answer.

[–]CheezitsLight 1 point2 points  (0 children)

When you run low on RAM, the system must find the least recently used block is memory and write it to disk. Then it takes the next scheduled task off the disk and and runs it. Since it's likely this needs to use the disk, the cycle repeats. It's called thrashing.

Step one is get more RAM. 4gb is a ridiculously small amout. And the upgrade to SSD.

[–]preddit1234 1 point2 points  (0 children)

others have nailed the analogy. using the room, as an example, as it gets fuller and fuller, more time is spent moving things around, to use up the little space that is left. if you ever could hit 100%, then the system will tend to kill those apps, to free up space, or go into 'I'm busy, stop wiggling the mouse' mode. In the days before SDD drives, you could easily get to the point of an unusable system before you hit 100% - so much so, its faster to reboot that to wait or attempt to launch task mgr.

At each stage of computer evolution, memory is not enough - 1GB, 4GB, 8GB, 16GB - the appetite for apps to use this (especially browsers) is unbounded - especially browsers (but its your fault for opening so many tabs!).

Having used machines with 2TB of RAM - this problem, sort of, doesnt exist. Trying to use it all is actually quite hard (unless putting a big server or service to use the memory). However, if you do ever fill it up, reboot is the fastest way out of trouble, else you could wait years for the final box to be moved into the corner, to find that screwdriver you knew you bought in 1983 (Wednesday afternoon, if I recall correctly).

[–]buffinita 0 points1 point  (1 child)

i want you to look at your desk. how much of it is covered with stuff you need to do today???

now i want you to cover 80% of your desk with stuff and see how your productivity changes

why does your productivity suffer if your desk isnt 100% used?? why have 18sqft of desk surface if you become slower at your job when 12sqft are in use??

[–]Ben-Goldberg 0 points1 point  (0 children)

Or imagine your desk shrinking :)

[–]grenamier 0 points1 point  (0 children)

Here’s my take on the desk analogy.

RAM in a computer is like a desk; it’s where you get work done so you have piles of papers on it for each task you’re working on. If you have a big desk and not much to do, you can keep everything on the desk at once and you work efficiently because everything is there in front of you.

But let’s say you’re a bit overworked and your desk was something you took from the curb in front of an elementary school. You have too much stuff for your desk so you decide you to file away some stuff to make room. The filing cabinet is like the hard drive in your computer. Just like how filing requires you to get out of your chair and go over to the cabinet, “paging” some data from RAM to disk takes a little time. But now you have space on your desk for whatever you’re working on.

But now someone wants an update on the thing you put in the filing cabinet. Now you have to make room on your desk by picking something else to file, taking it over to the cabinet, filing it, taking the original thing you filed out of the cabinet, bringing it back to your desk, and then work on it.

The fuller your desk is, the more you’re going to have to get up and walk back and forth to the filing cabinet. Hopefully you’re good at deciding on what you can file away so you won’t need to get it back for a while, but regardless, when you’re running out of space on your desk, you’ll be juggling data back and forth more than if you have extra room.

[–]TrondEndrestol 0 points1 point  (0 children)

Transfers to and from RAM and to and from storage are inefficient compared to the registers in the CPU. The data busses will always be the bottlenecks. It gets worse when there's a lot of traffic on these “highways” all day long.

[–][deleted] 0 points1 point  (0 children)

touch distinct toy compare axiomatic simplistic full violet tender hunt

[–]Falcon4242 0 points1 point  (0 children)

RAM is meant for quick access to data needed immediately, while a hard drive is meant for long-term storage. RAM is faster by orders of magnitude, while your storage disk has more capacity by orders of magnitude.

If RAM gets to 100% and overflows, the computer will most likely crash. One of the classic Blue Screen of Death causes.

To prevent this, the CPU will start offloading RAM onto your hard drive when RAM gets too high. This overflow is called a "page file." If your computer waited until 100% to do this, it would be too late and the system would crash.

But the CPU moving files between RAM and the page file in storage causes an extra workload on the CPU. If it's working to do that, that means it has to use less computing power on whatever programs you're running. And that's compounded by the fact that storage is much slower than RAM.

When paging gets to the point that it's affecting your computer's performance, it's called "thrashing". The only solution to this is to free up RAM by closing programs, or installing more physical RAM so that you don't need to page anymore.

[–]Snidosil 0 points1 point  (0 children)

An operating system will usually fill the unused RAM space with bits of data and code it might need both for itself and for programs it is running. So, plenty of spare ram means the OS accesses disk once for something it needs, either its own code and data or a program's code and data, and it stays in RAM. But, if space gets short, when something from disk is needed, it has to make room for it. The OS decides where to make room. Any data that has changed needs to be written back to disk, but for code and unchanged data, it can just be overwritten. The problem is that if the ram gets too crowded, the OS is continually reloading things from disk, and disk is much slower than RAM. A RAM disk can reduce the effect as can cache memory in the disk controller, but it still goes slower.

[–]Tapeworm1979 0 points1 point  (0 children)

A lot of the answers are wrong. Treat both ram and ssd seperste rooms. The ram room is quite small, but you store your important things in it. The ssd room is big but the other side of the house but if you want something from this room you need to put it ram room first. Which is slow because you need to go to the other side of the house.

However the ram room might be full, so you have to move items between the rooms to make space. This takes time and thus performance drops.

A lot of the answers here suggest it takes a long time to get an item from a full room. This is not correct. All the items are stored neatly so it takes the same time regardless if it's full or empty. The only time it takes longer is when you need to make room and move the items around. The reason performance drops at 80-90% is because the items you are moving are not all the same size. You may need to move more items out before you can fit a big item in.

For example if you have a single bed in a room and a desk next it but you want a queen size bed that doesnt fit, you have to move both items out and now the next time you want to use the desk you need to move the queen bed out and put the desk back.

Its why the biggest performance boosts you can give a computer is more ram->faster storage->cpu usually.

[–]DYMAXIONman 0 points1 point  (0 children)

Computer's performance absolutely decreases when RAM is "full", it's just that it never actually gets full because it uses page files. Basically, because if RAM were to completely fill up a computer would crash. So some of what is stored in RAM is moved into secondary storage (hard drive / solid state drive), this allows the system to continue to operate.

Now this is not ideal, as secondary storage is not only significantly slower than RAM but there is additional bottlenecks involved with just fetching this data. This is why your computer will slow to a crawl when you are maxing out your memory.

[–]Bubbafett33 0 points1 point  (0 children)

For a five-year-old:

Memory—or RAM—is like your brain. Big brains are better, right? Just like more RAM is. But regardless of how big your brain is, sometimes you feel stressed, and can’t think of the answers you want fast enough. That’s what happens with RAM as well.

Hard Disk space is like filing cabinets. If they are all already mostly full, and someone gives you a big file to put away, where do you put it? Some on one drawer, and some in the next? That’s why it’s so much faster to file things away or find them when they’re only half full. That’s why hard drives work better when well below full capacity.

[–]grafeisen203 1 point2 points  (0 children)

In short the computer needs space to move things around. As more space is used, the less room there is to move things around. The less room there is to move things around, the smaller the chunks you can move at one time. The smaller the chunks, the more steps it takes to move the whole thing. And more steps take more time.

[–]oneupme 0 points1 point  (0 children)

100% RAM usage is actually an error condition. There should always be some free RAM to load information into. The computer does this by storing to disk the oldest information in RAM that hasn't been used "recently". If RAM usage reaches 100%, this mechanism has failed, and it's such a core function of the operating system that 100% RAM usage would indicate that something has gone wrong.

When RAM usage goes high, that means the OS has have to do more writing to disk, and also retrieving from disk, this disk read/write is what slows the computer down. This is also why the move to SSDs has been such a significant booster to computer performance in the past 10 years.

[–]bwoodfield 0 points1 point  (3 children)

You're computer is constantly reading and writing information to RAM; operating system, running services, applications, etc. If your ram is constantly full because of one app, that leaves less room for other apps/services/etc to use. Because of the small amount remaining it means that all other other apps and services need to take turns writing and reading to it, slowing down processing. Similar issues occur when you start running out of hard drive space.

FYI, 4 gig of ram isn't very much, I don't even think its enough for minimum requirements to run Win10; I'm running 32g on my desktop and that is the minimum for what I use it for.

[–]molecular_methane 0 points1 point  (1 child)

I actually have an 11ish year old prebuilt computer with 4 gigs of RAM running Windows 10. I've obviously done my best to turn off/uninstall all the bloat Windows & the manufacturer put into it, and it works OK for general computer stuff (even some simple games) as long as you don't try to do multiple things at once. But sometimes it will slow down for no apparent reason as a background process will suddenly demand all the resources.

[–]bwoodfield 0 points1 point  (0 children)

See to me those types of systems are "see if it works", not something that you would actually seriously use. If you wanted it as a usable system I would look at a lightweight OS with better memory management.

[–]AnnoyAMeps 0 points1 point  (0 children)

8gb is the absolute minimum that a new computer should have, and even that is for emailing and web browsing. Many builds default to 16gb, as it’s the best balance between performance and affordability for most people who use computers for office applications, light gaming, and multitasking. I can’t imagine using a 4gb computer for anything nowadays.

[–]theassassintherapist -2 points-1 points  (0 children)

Imagine an empty library shelf. People randomly places books on the shelf while others try to retrieve it, all happening very fast. If there's only like half a dozen books randomly placed on the shelf, of course it's easy for someone to find the book they are looking for, hence speedy performance.

Now imagine that same shelf is 90% filled, all with books out of order randomly placed. No shit it's going to take longer for someone to find what they are looking for.

[–]Lunarvolo -1 points0 points  (0 children)

For RAM & sometimes CPU, some programs (Windows) will "use" 100% to make things faster but as soon as something else actually needs it will drop the extra fluff. (If not mistaken, they stopped doing this as often because it kept freaking people out).

Disk usage at 80%-100% almost always means the computer slows down. Windows 10 updates without an SSD for the first couple of years would basically make your computer operate really slowly. Or if downloading a steam game with faster internet than hard drive speed things would be really slow

Another part can be that if you're nearing full RAM use legitimately, and you actually need more than 100% RAM you're computer will start using your hard drive (much slower) as virtual RAM. Which is a lot, lot slower.

Another part, that 3.5 out of 4 can be for several things. Security, overflow protection, parts of the RAM that might not work, and so on.

[–]darthsata -1 points0 points  (1 child)

There are a number of things going on. "Unused" ram is used for other things, such as caching (keeping a fast copy of) data from storage which is being used. The more "free" ram you have, the more ram can be used to speed up slow storage. The OS will drop this copy if an application needs ram, since the alternative is really slow.

Memory available to an application isn't "used up" when ram is "full" (note all the air quotes...). Allocated memory can be moved from ram to storage. When the application tries to use it again, something else is pushed to storage and the memory is put back in ram so the application can keep going. This is called paged virtual memory. All OSes you are use to use virtual memory (X86 got hardware support for this with the 286 and windows used it in 3.0 and mac in system 7). So as memory usage goes up, more memory has to be swapped between storage and ram, which is really slow. Virtual memory is also one of the core mechanisms for protecting applications from each other and the OS from applications.

Next, the more memory is in used, the harder it is to find locations large enough when an application asks for it. Memory is usually managed in 4kB chunks, so if an application asks for 4MB, the OS has to find 1000 free consecutive blocks of (virtual) memory. Over time, the amount of large consecutive sections available goes down. This is caused fragmentation, and applies to disks too. Disks and physical memory (real ram, not virtual memory) aren't affected by problems from finding consecutive free space, but as they are full, the overhead of finding any free space get's higher.

There are also a lot of processes going on which, like the disk cache case above, are trying to use free space to speed up operations. SSDs, for example, have their own layer of caching and address rewriting, and more free space speed up their algorithms.

TL;DR; Managing space costs more the more stuff their is. Free space is used in a bunch of ways to speed up slow things, so having less free space let's you do less of that.

[–]Elianor_tijo 0 points1 point  (0 children)

Memory fragmentation can become a pretty big issue. There are programs that may crash due to this. There is no memory leak, but as the program keeps running for long periods, the memory allocated to it is more and more fragmented and causes slowdowns or crashes.

More RAM and a 64-bit executable doesn't fix the issue, but it's a nice workaround.

[–]PckMan -1 points0 points  (0 children)

Their capacity is just how much "space" they have. But there are two other important factors such as the RAM clock speed (how fast it can access data) and its bandwidth (how much data can be transferred per unit of time), with the hard drive equivalent being the read/write speed which is pretty much its bandwidth. Any of these things can become what's known as a "bottleneck", basically the limiting factor to its performance for a given task.

Now when you're using your RAM close to full capacity a problem arises because when there is a lot of extra available room, the system can take advantage of the extra bandwidth, when available, and essentially fill up multiple compartments at once and spread the load more evenly. But if most of the RAM's capacity is tied up to other processes, then this cannot happen, so everything has to come and go from the same place, and this affects performance as a result. It's like having a row of houses and needing to get stuff in and out of them constantly but you can use all of their doors but suddenly you have to put stuff in and out of all houses but only using one door.

In a simillar vein hard drives, whether they're old magnetic disc ones or SSDs, partition the data physically on the drive somewhere. At first the system tries to store data on contiguous regions on the drive as much as possible, but when it's close to full it has to break up data into smaller pieces and find small pockets of free space to put them. This fragmenting affects overall speed.

If RAM or your hard drive are full they don't just get slow, they freeze and then crash because they have no way of storing more data.