Trying to put a file into virtual memory many times
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I mean it's a pretty big world there are more than 6 billion people and you guys just want to dismiss something that you don't think exists yet. So you're saying if some new technology came out to make ourselves immortal, you would just dismiss that and let yourself die because you don't believe that it exists????
I'm just asking for help on how to fill up my virtual memory space... This is NOT about anything else.
Last edited by Thirdeyematt; 09-01-2016 at 03:56 AM.
so to help you: what have you really tried, where is your code, where did you stuck? Probably we can help you to improve your code to do something related to "fill up my virtual memory space".
From the other hand we did not say we don't believe, we told you we know it won't work. As I already told you the content of the virtual memory is stored on a hard disk. Virtual means that is no real RAM, but .... look at here: wiki virtual memory
The stored images, sounds, apps and anything just stored as bits, a huge amount of 1 and 0, like this: 100101010101010101.
You will not find images, sounds on the disks, just these 0s ans 1s. There are softwares to make these recognisable by humans, like music players or image viewers, without them they are only just bits.
Finally, the statement: " putting a file into virtual memory is technically being used by the computer" is incorrect. Putting a file into virtual memory means just copying those bits and bytes from here to there without using a music player or any other application. So during that process it won't be played, won't be interpreted as music at all...
Virtual memory from a programmer perspective is when you allocate ram that doesn't exist. Most times this allocation succeeds (because of the compiler and language handling it behind the scenes), but it's basically ram to disk. We call this swap in the land of linux. Once you run out of both types of ram, the kernel protects itself by removing those things using resources. Not that this is the terminology that you're referencing. Or at least your understanding of it.
I just am not sure how to put the file into virtual memory 100,000 times instead of once, I am having trouble finding online how to do this... Some sort of stack add. I will continue looking but maybe someone has an idea or know how I could write some sort of code to do this?
You still don't know what you are doing. tmpfs uses swap.
and it will use swap when reading the same file multiple times as reading a file gets loaded into cache, and when cache starts to run low, it WILL page out the least recently used pages.
technically you may create a filesystem on tmpfs, and mount into /ramdisk (for example).
Code:
mount -t tmpfs -o size=100M,mode=0755 tmpfs /ramdisk # << change the size
You can use any size you want, for example the full size of your ram + swap + even more (you can try).
Now you have a filesystem, and you can put/copy your file into /ramdisk. You can copy it several times using different filenames, so you can have file1.dat, file2.dat, file1000.dat, .....(the number of copies depends on the size you specified). And they will be stored automatically in swap/virtual memory as soon as the real memory is full.
But again, "putting a file into virtual memory is technically being used by the computer" is incorrect.
That is something like: buying beer and putting the bottles into your kitchen does not mean the beer is in use.
technically you may create a filesystem on tmpfs, and mount into /ramdisk (for example).
Code:
mount -t tmpfs -o size=100M,mode=0755 tmpfs /ramdisk # << change the size
You can use any size you want, for example the full size of your ram + swap + even more (you can try).
Now you have a filesystem, and you can put/copy your file into /ramdisk. You can copy it several times using different filenames, so you can have file1.dat, file2.dat, file1000.dat, .....(the number of copies depends on the size you specified). And they will be stored automatically in swap/virtual memory as soon as the real memory is full.
But again, "putting a file into virtual memory is technically being used by the computer" is incorrect.
That is something like: buying beer and putting the bottles into your kitchen does not mean the beer is in use.
Thank you for your reply, I think that this is getting closer to finished. Ok... So I guess I didn't mean that the computer was using the virtual memory, I just meant that putting a file into virtual memory is exactly what I am trying to do... So if that is the code for putting a file into virtual memory...
How do I go about writing code that will change the file name of the file every time I add it to the virtual memory?
And then is there a way to write a code that will put/copy the file into virtual memory instead of having to hit paste 100k times?
Thank you shadow!!! I believe it worked!!! . Does it need to be in bash for it to work, or can I run that command in terminal after I have installed bash?
The reason I say that is because I have tried installing bash and then when I double click the bash executable nothing happens?
Also, what is the code to clear out the virtual memory so I can put a new image file in?
Well I took a look at the manual, I didn't see a cp command, does this have the function of the map file command without actually having to declare an array that the file is being mapped to?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.