Linux - Newbie This 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.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
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.
|
 |
|
09-01-2016, 03:55 AM
|
#16
|
Member
Registered: Aug 2016
Posts: 31
Original Poster
Rep: 
|
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.
|
|
|
09-01-2016, 04:18 AM
|
#17
|
LQ Addict
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 24,021
|
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...
|
|
|
09-01-2016, 06:07 AM
|
#18
|
Senior Member
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,908
|
so you are another that thinks magic works?
|
|
|
09-10-2016, 06:15 PM
|
#19
|
Member
Registered: Aug 2016
Posts: 31
Original Poster
Rep: 
|
Well the code is too slow... I do not believe Java will be able to fill up the virtual memory fast enough.
So how do I write a program that will be able to use tmpfs or ramfs to make the same temporary file over 20000 times all with different names?
|
|
|
09-10-2016, 06:24 PM
|
#20
|
Senior Member
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,908
|
Read the documentation on mount.
|
|
|
09-10-2016, 06:57 PM
|
#21
|
Senior Member
Registered: Feb 2003
Distribution: debian
Posts: 4,137
|
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.
|
|
|
09-14-2016, 06:40 PM
|
#22
|
Member
Registered: Aug 2016
Posts: 31
Original Poster
Rep: 
|
Ok so I know the coding to clear the virtual memory with tmpfs. Also, here is the website I found to store files into virtual memory with tmpfs:
https://www.howtoforge.com/storing-f...ory-with-tmpfs
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?
|
|
|
09-14-2016, 06:58 PM
|
#23
|
Senior Member
Registered: Nov 2011
Location: London, UK
Distribution: Debian
Posts: 1,950
|
Bad luck  it says
Quote:
This article shows how you can store files and directories in memory instead of on the hard drive [with tmpfs]
|
You don't use any actual swap on disk until you have made full use of any unused RAM.
I'd suppose you could call that RAM usage virtual memory?
|
|
|
09-14-2016, 08:59 PM
|
#24
|
Senior Member
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,908
|
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.
https://www.kernel.org/doc/Documenta...tems/tmpfs.txt
|
|
|
09-15-2016, 02:35 AM
|
#25
|
LQ Addict
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 24,021
|
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.
|
|
|
09-15-2016, 10:15 AM
|
#26
|
Member
Registered: Aug 2016
Posts: 31
Original Poster
Rep: 
|
Quote:
Originally Posted by pan64
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?
|
|
|
09-15-2016, 11:08 AM
|
#27
|
Senior Member
Registered: Feb 2003
Distribution: debian
Posts: 4,137
|
in bash?
$ for COUNT in {1..100000}; do cp FILE /location/FILE$COUNT; done
It's not rocket science, read a book, or man page, or learn the secrets of F1 (F3 on mainframes) or help.
or
$ for COUNT in {100001..200000}; do cp FILE /location/FILE$COUNT; done
If you want all the files to have the same number of digits without fancy padding logic.
|
|
|
09-15-2016, 07:04 PM
|
#28
|
Member
Registered: Aug 2016
Posts: 31
Original Poster
Rep: 
|
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?
|
|
|
09-15-2016, 07:20 PM
|
#29
|
Senior Member
Registered: Nov 2011
Location: London, UK
Distribution: Debian
Posts: 1,950
|
Read the manual.
|
|
|
09-15-2016, 08:59 PM
|
#30
|
Member
Registered: Aug 2016
Posts: 31
Original Poster
Rep: 
|
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?
|
|
|
All times are GMT -5. The time now is 11:39 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|