It is not always the case that the entire program code is loaded into memory
Oh really? Why is this so?
It is not always the case that the entire program code is loaded into memory
Oh really? Why is this so?
It is not always the case that the entire program code is loaded into memory
Oh really? Why is this so?
Because the OS has the ability to do memory mapping.
http://en.wikipedia.org/wiki/Memory-mapped_file
This way it can intelligently load the parts that are actually used, while setting aside the memory addresses for the whole thing if needed.
The executable itself along with all the associated libraries required less than 45MB, or just under 2% of the total size.
That is strange. My game is quite small in content. But the executable alone is 85.4 MB! Should I not be putting my assets(audio, art, game logic in the exe)? I know these files are there because when I extracted the executable java jar file, the folder that contains the mentioned assets appear.
So I must be doing something wrong, if the executable jar file is so big even for a game with small content(2 minutes of doing everything)!
JARs don't really work like normal executables. They're more zip files that include the executable files along with other stuff. Not sure if it's accepted practice to put your assets in there.
It is not always the case that the entire program code is loaded into memory
Oh really? Why is this so?
Because the OS has the ability to do memory mapping.
http://en.wikipedia.org/wiki/Memory-mapped_file
This way it can intelligently load the parts that are actually used, while setting aside the memory addresses for the whole thing if needed.
Do all OS from all brands of computers have this? What happens if a programmer coded the game to load the data for map 1 even when the player is at map 0? Asumming the section of the map are traveled linearly in a numerical order. Would the memory mapping still kick in or follow the code the programmer has written for the game?
JARs don't really work like normal executables. They're more zip files that include the executable files along with other stuff. Not sure if it's accepted practice to put your assets in there.
Oh Interesting. The strange thing is that I seen people make java games and their games have more assets than mine. But their jar file is super small not even hitting the 10 MB mark and their game boots up by clicking the exe while I actually have to extract a folder from the jar rename it to a folder called "src" and then have the game read that folder which makes the file size containing the exe and the folder equal to roughly twice the size of the jar file.
Memory mapped files are a feature that has to be explicitly coded to use. So it works however the programmer write it to work.Do all OS from all brands of computers have this? What happens if a programmer coded the game to load the data for map 1 even when the player is at map 0? Asumming the section of the map are traveled linearly in a numerical order. Would the memory mapping still kick in or follow the code the programmer has written for the game?Because the OS has the ability to do memory mapping.It is not always the case that the entire program code is loaded into memory
Oh really? Why is this so?
http://en.wikipedia.org/wiki/Memory-mapped_file
This way it can intelligently load the parts that are actually used, while setting aside the memory addresses for the whole thing if needed.
I actually have to extract a folder from the jar rename it to a folder called "src" and then have the game read that folder which makes the file size containing the exe and the folder equal to roughly twice the size of the jar file.
I actually have to extract a folder from the jar rename it to a folder called "src" and then have the game read that folder which makes the file size containing the exe and the folder equal to roughly twice the size of the jar file.
You can use the JarFile class to open your own file, search through the file listings for the right JarEntry, and then open it as an input stream decompressing it as you stream the data out the same way any .zip decompression library works. For some resources this can happen automatically. No need to decode the file out to disk unless you have some disk-based need.
It turns out the JarEntry is another Java class built in to the Java Standard Library. So with the above mentioned Java classes, the jar will just read the files embedded in the jar exe?
One thing I should mentioned is that I am using FileInputStream. Here is my Java game code for reading the art assets.
image = ImageIO.read(new FileInputStream(new File(animations[i])));
Does the above code being FileInputStream have any effect on when my java jar exe not running when I double click on it (unless I extracted the folder from the jar exe)?