There are use cases where I can't have a lot of ram, and sometimes due to docker based services doesn't always provide more than 512mb/1gb of ram, or if I run multiple rust based gui apps and if each take 100mb of ram normally, how can I implement a swapfile/ virtual ram to exceed allotted ram? Also os level swapfiles don't let users choose which app can use real ram and which swapfile, so it can become a problem too. I want to use swapfile as much as possible, and not even real ram, if possible. Users and hosting services provide with lot of storage usually (more than 10gb normally) so it would be a good way to use the available storage too! If swapfile or anything like that aren't possible, I would like to know if there is any difference in speed and cpu consumption between "cache data in ram" apps and "cache data in file and read it when required" apps. If the latter is slow normally and not as efficient as swapfiles, I would like to know the possible ways how os manages to make swapfiles that efficient than apps.
How To implement swapfile cross operating system
215 Views Asked by Ren Hiyama At
1
There are 1 best solutions below
Related Questions in RUST
- Borrow mutable and immutable reference in the same block
- Linking to a static lib compiled with MSVC
- Using a no-method trait implementation in a different module
- No error for two traits implementing the same method
- How are the generic functions and types stored in an rlib?
- Is it possible to find an element in a Vec<T> and remove it?
- What does & actually do?
- unresolved name rand::thread_rng
- Use of undeclared type that is defined in another file
- Creating byte buffers in rust
- What's the difference between filter(|x|) and filter(|&x|)?
- How to convert iterator of chars to String?
- Correct idiom for freeing repr(C) structs using Drop trait
- Rust String concatenation
- Can I mark a function as deprecated?
Related Questions in RAM
- C# console application - Unhandled exception while finding the Available and free Ram space.Getting exact answer in windows forms application
- Do pictures ever get stored in RAM?
- Find Ram/Memory manufacturer in Linux?
- Android Studio randomly disappears/crashes with 7GB Ram
- Search for file in archive and load it into memory
- Upgrading RAM on a 32-bit system to boost up android studio?
- sort runs out of memory
- Android RAM usage error with broadcast receiver in service
- System.Management, Management Object Searcher, and RAM
- How to calculate RAM usage of a image when decoded
- JavaFX high memory usage
- Could AWE or anything else could help to use more SQL memory
- Whole Oracle database in memory
- Is it possible to sort 3 GB of java on 32 bit system using JAVA
- Get Ram Information OSX
Related Questions in MEMORY-EFFICIENT
- Efficiently finding the count of column values for distinct rows in a dataframe in r
- Faster alternative to populating a pre-allocated data frame using a for-loop
- Time running program varying wildly on each try?
- Inefiecient code on loops. 10000000 loop challenge.
- window click event vs a lot of buttons click event
- Instantiating C++ objects from QML has tremendous memory usage overhead
- Fast row removal and addition in pandas.DataFrame without reallocation
- What's the difference in memory between creating an object inside and outside of a loop
- Does Slicing `a` (e.g. `a[1:] == a[:-1]`) create copies of the `a`?
- How to parse xls file containing multiple sheets, within 50MB of memory, in Java
- How can I parse a csv in low memory, using some parser in Java?
- get all indexes of value nil in array
- Python - dividing a list-of-lists to groups
- Efficient way of computing statistics for large/imprecise amount of data
- create single bytes instance from sequence of memoryview
Related Questions in SWAPFILE
- Can a Nodejs process uses more memory than the available physical memory (by using swap memory)?
- execute commands in a CoreOS cloud-config (e.g. to add swap)
- OSRM extract and best swap stxxl location on 2 HDs
- Many detached boost threads segfault
- Is there any in-app linemode equivalent of "vim -r"?
- How to force a paused process' memory into swap?
- How to find the unique swap page by virtual address when page fault
- I need docker instance to NOT utilize the host swap
- How To implement swapfile cross operating system
- How can I see the option in Vim to "[D]elete" a swap file?
- swapoff/swapon when script is running
- How to change the folder path for swp files in Vim
- Is using swap space a good idea in a python program?
- Is there a way to force a hard RAM-usage limit for R, resulting in it using swap space after it is hit?
- MongoDB Out of Memory
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
An application does not control whether the memory they allocate is allocated on real RAM, on a swap partition, or else. You just ask for memory, and the OS is responsible for finding available memory to give to you.
Besides that, note that using swap (sometimes called swapping) is extremely bad performance-wise. How much depends a lot on your hardware, but it's about three orders of magnitude. This is even amplified if you are interacting with a user: a program that is fetching some resources will not be too bothered if it has to wait one minute to get them instead of a few milliseconds because the system is under heavy load, but a user will generally not be that patient.
Also note that, when swapping, the OS does not chose which application gets the faster RAM and which ones get the swap memory at random. It will try to determine which application should be prioritized, by how much, etc. based on how it was configured (at least for the Linux kernel), so in reality it's the user who, in the end, decides which applications get the most RAM (ahead of time, of course: they are not prompted each time the kernel has to make that decision with a little pop-up...).
Finally, modern OS allow several applications to allocate memory that overlap, as long as each application is not fully using the memory it asked for (which is kind of usual), allowing you to run applications that in theory require more RAM that you actually have.
This was on the OS part: now to the application part. Usually, when you write a program (whose purpose is not specifically RAM-related), you should not really care for memory consumption (up to a certain point), especially in Rust. Not only that is usually handled by the OS in case you used a little bit too much memory, but when it's possible, most people prefer to trade a little more memory usage (even a lot more) for better CPU performance, because RAM is a lot cheaper than CPU.
There are exceptions, of course, in which the memory consumption is so high that you can't really afford not paying attention. In these cases, either you let the user deal with this problem (ie. this application is known to consume a lot of memory because there are no other ways to do this, so if you want to use it, just have a lot of memory), as often video games do, or you rethink your application to reduce the memory usage trading it for some CPU efficiency, as for example is done when you are handling graphs so huge you couldn't even store them on all the hard disks of the world (in which case your application has to be smart enough to be able to work on small parts of the graph at the time), or finally you are working with a big resource but which can be stored on the hard disk, so you just write it on a file and access it chunks-by-chunks, as some database managers do.