General Development

Simulated file system – Rocky20


Junior Member

Posts: 2
From: Virginia, MN USA
Registered: 02-03-2006
I am simulating a file system in Java. I will be using a linked list to represent the disk nodes. When I increase the maximun number of nodes, I do not want to increase the ram used in running the program. I will be using randomAccessFile to read from and write to random parts of the file system. I would appreciate any ideas.

But because of his great love for us, God, who is rich in mercy, made us alive with Christ even when we were dead in transgressions - it is by grace you have been saved Ephesians 2:4-5 (NIV)



Posts: 2337
Registered: 02-01-2005
Hi Rocky20! Welcome to CCN!

Sorry to be offtopic, but do you know of any good Java tutorials for experienced programers who have learned another language? (Sun Documentation Doesn't count! )

All Your Base Are Belong To Us!!! chown -r us ./base

``After three days without programming, life becomes meaningless.'' -- Tao of Programming Book 2

[This message has been edited by CPUFreak91 (edited February 04, 2006).]



Posts: 2220
From: New Albany, Indiana, U.S.
Registered: 10-08-2004
dude... this totally is confusing for me lol... But welcome Rocky20!!
You will soon find out I am the board spaz, also Realm Master.... lOL!!

In the stock market, you must buy high and sell low...Wait! That's not right!
Yes, I can be intelligent at times!!



Posts: 224
From: Des Moines, IA
Registered: 08-16-2004
Nodes to handle a virtual filesystem shouldn't take up that much memory. Unless you are storing the actual file contents in the list...

A linked list is a dynamic array which requires you to allocate more memory after you start to run out. The nice part about linked lists is that you don't have to set up a static array that could take up a lot more space than a user needs (or possibly won't be enough). So you can either have one huge array that may not handle everyone's needs or a dynamic array that can be small or large. I hope that makes sense.

Java does a pretty good job of cleaning up the memory that is unused so I wouldn't worry too much about memory consumption unless you are building this for a cellphone or some other small electronic device.



Posts: 129
From: Amersfoort, the Netherlands
Registered: 12-23-2002
You always use more ram if you increase the maximum number of nodes used. You could make all your object serializable and serialize them to disk if you want to. You can use WeakReferences to reference your files in memory so it works more like a memory sensetive cache.

The idea would than be this:
- On creation of a new file, write it to disk, and save a copy of it in your linkedList referenced by a WeakReference
- When you want to access the file, first attempt to get it from the linkedList, if its gone, load it from disk and put it back.
- After writing save it back to disk.

Something like that.

I was actually thinking of starting a project which could solve the problems you have. Unfortunaly I have so much going on right now that I have to choose my battles. It would take a random access file and build it into a sort of partition. Then you can do anything with it, from a huge array to a file system to a database. *sigh* I wish I had more time.

[This message has been edited by vincent (edited February 06, 2006).]