Stack Size/ja
{{#customtitle:スタック・サイズ|スタック・サイズ — MapToolDoc}}
スタックとは?
When MapTool starts, the Java Virtual Machine (the program that lets MapTool run on your computer!) configures a number of settings for the program. Two of these settings involve the available memory given to MapTool: main memory, and the stack.
MapTool の起動時、JAVA仮想マシン(これは君のパソコンでMapToolを動かすためのプログラムだ!)は MapTool 用にいくつかの設定を行う。そのうちの2つの設定は MapTool が使用するメモリー、メイン・メモリーとスタックに関するものである。
メイン・メモリーの割り当て
The main memory allocated to MapTool simply indicates how much of your computer's RAM MapTool can play with - if you have, for instance, 2GB of RAM, you can tell MapTool that it can play around with 1GB; likewise if you want, you can say "MapTool can only use 256KB of RAM!"
MapTool へのメイン・メモリーの割り当ては単純にパソコンのRAMをMapToolがどれだけ利用可能かを示せば良い。たとえば、2GBのRAMがあるなら、MapTool に潤沢な1GBのメモリーを与えても良いし、望むのなら「MapToolは256KBのメモリーしか使っては行けません!」ということにしても構わない。
スタック・サイズ
There is another memory amount that Java sets up when MapTool launches, and this one has to do not with the total amount of memory that MapTool gets, but the amount of memory any particular thread of a program can eat up at a given time. This memory is called the stack.
MapToolが利用可能なメモリー総量以外に、起動時に Java が設定するメモリー量に関するもう一つの設定は、プログラム内の各スレッドが一度に利用可能なメモリー量のことである。このメモリーをスタックと呼ぶ。
The stack is especially important when you are using macros to perform calculations: the more complex a macro gets (and some macros can get very complex!) the more stack memory it will consume.
このスタックは計算を伴うマクロを使うときに特に重要なものだ。複雑なマクロは、より多くのスタックメモリーを消費するからだ(いくつかのマクロはとてつもなく複雑だ!)。
Eventually, a macro can get so complex, it eats up all the stack it is permitted, and then cries out for more. When this happens, you get a Stack Overflow error, and the macro will simply Not Work.
結局のところ、マクロは複雑になるもので、利用可能なスタックを食いつくすと更なるメモリを求めてだだをこね始める。そしてそのとき、Stack Overflowのエラーを吐き出し、マクロは動かなくなってしまう。
スタックの設定
In the beginning, MapTool used whatever default stack size Java felt like setting. The actual amount varied from computer to computer and operating system to operating system, but it was generally enough for the simple macros that were in use at the time.
As the power and flexibility of the macro code increased, macros began to bump up against the limits of the default stack, and users began adjusting their stack size to compensate.
.BATや.SHでのスタックサイズの設定
One of the ways to start MapTool is via the various batch files that are included when you download and unzip a copy of MapTool. These files are called things like Launch Maptool-512M-Memory.bat (for Windows machines) and Launch MapTool.sh (for Linux). The number in the filename indicates the amount of main memory allocated to MapTool. The contents of these batch files looks like:
javaw -Xmx512M -Xss512K -jar maptool-*.jar run
The critical pieces here are the ones that begin with
-X
. The first, -Xmx512M
indicates how much main memory (in this case, 512MB) is allocated to the Java virtual machine. The second,
-Xss512K
is how much memory is allocated to the stack (the "ss" is for "stack size"). In versions of MapTool prior to 1.3.b54, the
-Xss512K
is absent. To set the stack size allocated (overriding the defaults that are picked by Java or the value indicated), do the following:1. Open the batch file in a text editor like Notepad.
2. Edit the
-Xss512K
line to be another value, for instance, -Xss1M
or -Xss2M
(M is for megabytes, K is for kilobytes).3. Save the file, and then start MapTool using that batch file.
WARNING: When you are changing the stack size, the best settings are usually 512K, 1M, or 2M. DO NOT set it to 512M! That will cause Bad Things to happen.
MapToolLauncherを使用したスタックサイズの設定
If you start MapTool with the Windows launcher, the third field is where you can indicate stack size.
The Windows launcher defaults to a 2MB stack, which is perfectly acceptable for pretty much all uses. If you change it, that new value will be saved for the next time.
WebStart利用時のスタックサイズの設定
If you start MapTool using the Java WebStart option, you can change the settings here, too.
1. Go to The Launch Page
2. Click the CUSTOMIZATION link.
3. Enter the values you want to use when you WebStart one of the applications.
4. Click on the links above to start the application you wish to use.
Mac OSX でのスタックサイズの設定
These instructions apply to OSX users who have downloaded the .dmg file from the RPTools web site and installed MapTool from it. They were most recently tested on Snow Leopard 10.6.3. OSX users who are running MapTool using the WebStart approach won't need these instructions since the CUSTOMIZATION link on the Launch page allows the memory settings to be configured there.
(Unfortunately, Apple doesn't make this process easy. Their belief seems to be that the application provider should allow these values to be changed from inside the application but they didn't consider that the Java memory settings cannot be changed from inside Java. )
The installer in the .dmg creates what Apple calls an "app" -- it's a directory with the .app filename extension that contains all of the files necessary for the application. This includes the configuration file when the program is Java-based.
Here's the procedure for editing the configuration file (called a property list). Note that I'm describing the technique that uses the OSX TextEdit program because the only property list editor I have on my machine is under the /Developer directory -- which is an optional install for OSX so most people won't have it.
- Ctrl-click (or right-click) on the application icon (the filename should end with .app).
- Choose Show Package Contents and a Finder window will open.
- Open the Contents folder and locate the Info.plist file.
- Ctrl-click (or right-click) on that file and choose Open With > Other...
- In the Choose Application dialog that opens, locate TextEdit and double-click on it.
- The Info.plist file is now open. There is an entry in the file called VMOptions (mine was about two-thirds of the way down the file) that should be changed to match the memory characteristics your GM wants you to use. Here's what mine looks like in case you want a reference for the following steps:
- <key>VMOptions</key>
- <array>
- <string>-Xmx768m</string>
- <string>-Xms64m</string>
- <string>-Xss3m</string>
- </array>
- Replace your entries with the example text in Step 6. However, your GM may have directed you to use a particular value for the "maximum memory" setting. If so, replace the 768 number with the new maximum. The GM may also ask you to change the "stack size" amount -- that's the 3 number following the ss. (The 64 number never needs to be changed.) If you have other entries between the <array> and </array> lines, they should be removed because you're specifying completely new values.
- Use Cmd-Q and then choose Save. You can close the Finder window that opened as well.
You're all done!