Editing and deleting scripts and FAQ: Understanding Memory: Difference between pages

From MIPAV
(Difference between pages)
Jump to navigation Jump to search
MIPAV>Angelfish100
No edit summary
 
MIPAV>Olgavovk
 
Line 1: Line 1:
You can either edit a script while you are creating it, or you can edit any previously saved script. MIPAV saves the script in text format so that any text editor, such as Microsoft Wordpad or Notepad, can modify the file.
When MIPAV performs a function, such as visualizing an image file, it uses RAM on your computer. When you run MIPAV for the first time you must specify the maximum amount of memory (it calls the maximum heap size in the dialog box) that you would like to allocate for MIPAV, so it can take the full advantage of the memory resources available in your machine. The default value is 1000 MB.  The amount of memory you can allocate to MIPAV is limited by how much RAM is installed on your system.


'''Caution''': Editing scripts may cause serious problems if the script commands are not entered correctly. This task is recommended for more advanced users.<br />
== User permissions ==
MIPAV’s memory allocation is a program-level feature and it affects all users of a given MIPAV installation. You can only change the amount of allocated memory, if you are running MIPAV using an administrative account.


'''To edit scripts during creation'''<br />
== Memory limitations ==


Suppose you make an error while you are recording a script, or perhaps you've changed your mind about performing a specific action. It can be more practical to correct the problem right away.
{| class="wikitable" style="text-align: center; color: black;"
 
|-
To correct errors or make changes to scripts while you're creating and running them, simply click the Enable Edit button, in the Record New Script dialog box (Figure 18). Three things occur:
'''OS'''
1 It pauses the script execution.<br />
| '''Max memory
2 The scripting box in the dialog box turns from gray to white to indicate that you can now type, copy, or paste information into it and delete information from it.<br />
|-
3 The Enable Edit button changes to the Disable Edit button. If the scripting box contains actions that you want to erase, select the actions and delete them. To add new actions, you can type them into the scripting box directly. You can also rearrange actions by copying and pasting them.<br />
|Windows 32
 
|1.3 GB
{| border="1" cellpadding="5"
|-
|+ '''Figure 18. Record New Script dialog box (A) before and (B) after clicking Enable Edit'''
|Windows 64
|196 TB
|-
|Mac OS
|196 TB
|-
|-
|
|Linux 32
[[Image:Script_EnableEdit.png]]
|4 GB
|
[[Image:Script_DisableEdit.png]]
|-
|-
|
|Linux 64
<div class="CellBody">A</div>
|196 TB
|
<div class="CellBody">B</div>
|}
|}


'''Comment:''' These memory allocations are limited by how much RAM is installed on your computer.
== How can I allocate (more) memory for MIPAV? ==
=== When you are installing MIPAV ===
[[File:JvmMemoryLimit.png|500px|thumb|right|Installing MIPAV: the JVM Memory Limit tab]]
Starting [http://mipav.cit.nih.gov/download.php version 5.4.2] the easiest way to allocate memory in MIPAV is to do it when you are installing MIPAV. You can define the memory value in the JVM Memory Limit pane. The default value is set to 1000 MB. In the Pre-Installation summary pane, you can review memory settings, and then return back to the JVM Memory Limit pane and adjust them, if needed.
In case you figured out later that you need [[#HowMuchMemory | more memory]], you can still make adjustments using the Check java-runtime Memory Allocation dialog box [[#ChangeJava |options]]. See instructions provided for different operational systems below.
<div id="WindowsMemory"></div>
=== Windows users: adjusting memory settings ===
<div id="ChangeJava"></div>
<ol>
<li>Login to your computer under the administrative account, or under the user account who installed MIPAV. </li>
<li>Select Help &raquo; Memory allocation in the Main MIPAV window. The Check java-runtime Memory Allocation dialog box opens.</li>
<li>In the dialog box, change the maximum heap size number so it reflects the maximum amount of memory you might need. Note that for Windows 32, there is a 1.3 GB limit for memory allocation.</li>
[[File:MemoryAllocation.png|429px|thumb|center| The Change java-runtime Memory Allocation dialog box]]
<li>Click OK to close the dialog box.</li>
<li>You must restart of MIPAV for the changes to take effect. To exit MIPAV, select File &raquo; Exit. Then, restart the software.</li>
</ol>
Now, when more memory is needed to perform a certain task, MIPAV allocates it until the memory reaches the maximum heap size you specified. You can also access this dialog anytime and change the memory allocation parameter as you wish.
<div id="LinuxMemory"></div>
=== Linux users: adjusting memory settings ===
To change the amount of memory allocated for MIPAV use, you need to run MIPAV using an account that has write-permission to the directory where MIPAV is installed, such as an administrator. The heap size is set in the mipav.lax file located in the directory where MIPAV is installed. E.g. <span style="font-family:courier">/usr/share/mipav </span>(and not within your own user mipav folder, e.g. <span style="font-family:courier">~/mipav</span>). Therefore, you need to run MIPAV with the appropriate permissions to modify files in that directory for the one time when you use the memory allocation tool.
<ol>
<li> Login to your computer under the administrative account, or under the user account who installed MIPAV.</li>
<li> Select Help &raquo; Memory Allocation in the Main MIPAV window. [[#ChangeJava | The Check java-runtime Memory Allocation dialog box]] opens.</li>
<li> In the dialog box, change the maximum heap size number so it reflects the maximum amount of memory you might need.</li>
<li> Click OK to close the dialog box.</li>
<li> You must restart of MIPAV for the changes to take an effect. To exit MIPAV, select File &raquo; Exit. Then, restart the software.</li>
</ol>
<div id="MacMemory"></div>
=== Mac OS users: adjusting memory settings ===
Follow the instructions provided to the [[#LinuxMemory | Linux users]]. The only difference is that in Mac OS the <span style="font-family:courier">mipav.lax</span> file is called <span style="font-family:courier">mipav.command.lax</span>, but it looks just the same.
<div id="MipavLax"></div>
=== mipav.lax file ===
To adjust memory settings, MIPAV needs an access to the <span style="font-family:courier">mipav.lax</span> file located in the directory where MIPAV is installed. That’s why you need the appropriate permissions to make changes in this file. See also: [[MIPAV configuration files#LaunchAnywhere | MIPAV LAX files.]]
'''mipav.lax file: the allocating memory section'''
<blockquote>
LAX.NL.JAVA.OPTION.JAVA.HEAP.SIZE.INITIAL <br />
&#35;  ----------------------------------------- <br />
&#35;  Java start up heap size<br />
lax.nl.java.option.java.heap.size.initial=1048576000 <br />
&#35;  LAX.NL.JAVA.OPTION.JAVA.HEAP.SIZE.MAX <br />
&#35;  ------------------------------------- <br />
&#35;  Java maximum heap size <br />
lax.nl.java.option.java.heap.size.max=1048576000 <br />
</blockquote>
Note: For Mac OS <span style="font-family:courier">mipav.lax file</span> is called <span style="font-family:courier">mipav.command.lax</span>, but it looks just the same.
=== Other situations ===
[[File:OptionsMIpav.png|290px|thumb|right|The MIPAV Options dialog box]]
If you change the amount of allocated memory (the maximum heap size) and receive the following error message:
<blockquote>
"Heap size settings in the environment startup file either do not match those in the Preference file, or are non-existent. Memory Allocation will display so you can ensure this is correct." </blockquote>
And when you set a new number: in the Change java-runtime Memory Allocation dialog box, the following error message appears:
<blockquote>"Error writing to starting options file. No changes were made."</blockquote>
'''In order to fix that problem:'''
This is a common message when you have multiple versions of MIPAV installed on your computer and you switch between them. If you don’t want this warning to show up, you can avoid this by un-checking LAX/Preferences memory check option in the mipav.preferences file. This could be done via the MIPAV Options dialog box.
<ol>
<li> Select Help &raquo; Mipav Options in the Main MIPAV window. The MIPAV Options dialog box opens.</li>
<li> In the dialog box, go to the Other tab.</li>
<li> Un-check the LAX/Preferences memory check box.</li>
<li> Click Apply. The change will take place immediately.</li>
</ol>
<div id="HowMuchMemory"></div>
== How much memory does MIPAV require to run? ==
MIPAV requires a base of at least 10 Mb of random access memory (RAM). However, to correctly display image files and to quantify the data, you need to allocate more memory, use disk swap space, or install additional memory beyond this base. Each time MIPAV is installed, it always defaults to 100 Mb.
=== What affects memory requirements? ===
Memory requirements fluctuate depending on the size and number of image files that are open at the same time. Factors affecting memory requirements are the following:
1) the physical size of image files (i.e., 1.2 Mb); 2) the number of images opened, because working on more than one image file at the same time requires more memory.
'''Note:'''Java provides a method called Garbage Collector that clears all unnecessarily reserved memory. Generally, the software does this automatically, when free memory becomes very limited. However, you can run the Garbage Collector at any time to free memory (refer to [[#HowFreeMemory | How can I free memory?]] ). <br />
<div id="MemoryNeeded"></div>
=== How can I determine the amount of additional memory needed? ===
To determine the amount of additional memory needed:
<ol>
<li> Multiply the size of the largest image file that you want to process by 10.</li>
<li>Multiply the results by the number of image files that you want to display simultaneously.</li>
<li> Add this amount to the 10-Mb base memory to result in the total amount of memory typically needed.</li>
</ol>
==== Example 1: Memory calculation====
If an image file is 2 Mb and you only want to display one image file at a time, you must allocate an additional 20 Mb of RAM to the base memory of 10 Mb to result in a memory requirement of 30 Mb.
<blockquote>
2 Mb Size of image file x 10
<hr width="20%" />
20 Mb Memory required for displaying and processing 1 image file
+
10 Mb Base memory required for running MIPAV
<hr width="20%" />
30 Mb Total memory required
</blockquote>
==== Example 2: Memory calculation ====
If the largest size image file is 2 Mb and you want to display 3 image files simultaneously, multiply 2 Mb by 10. Then multiply that sum by 3. Add that total to the base memory of 10 Mb to yield a memory requirement of 70 Mb.
<blockquote>
2 Mb Largest size image file x 10
<hr width="20%" />
20 Mb Memory required for displaying 1 image file
x 3 Number of images to display and process simultaneously
<hr width="20%" />
60 Mb Memory required to display 3 image files
+
10 Mb Base memory required for running MIPAV
<hr width="20%" />
70 Mb Total memory required
</blockquote>
=== How can I determine how much memory is currently being used? ===
[[File:MemoryUsage.jpg|400px|thumb|right|The Memory Monitor dialog box]]
In the main MIPAV window, select Help &raquo; Memory Usage (or press '''Ctrl+M'''). The Memory Monitor dialog box appears. The dialog box shows how much memory is allocated and the amount of memory that is being used. The graph displays a pictorial representation of the ratio of allocated memory and amount of memory used. It shows the memory usage during the past 3 minutes and 45 seconds.
'''Note: '''You can leave this window open if you want to constantly monitor your memory resources.<br />
<div id="HowFreeMemory"></div>
== How can I free memory? ==
[[File:GarbageCollector.jpg|frameless]] As Java-based programs run, they often leave old variables, objects, or constructors in memory. For instance, if you delineate a VOI, the coordinates of the contours may remain in memory even after you close the image. Java provides a method called the ''garbage collector'' (or ''memory recycling'') that automatically freeing objects that are no longer referenced by the program and clears all unnecessarily reserved memory. Generally, the software does this automatically when free memory becomes very limited. However, you can run the garbage collector at any time to free memory by clicking the Garbage Collector button.
=== To free memory, do the following procedure periodically: ===


When you've finished editing the script, click Disable Edit. The record of script actions resumes. The scripting box turns gray and the Disable Edit button becomes the Enable Edit button.
<ul>
<li> Click the Garbage Collector button on the main MIPAV window.</li>
<li> Select Help &raquo; Memory Usage in the main MIPAV window. The Memory Monitor dialog box appears. Click Free Memory. The system clears all unnecessarily reserved memory.</li>
</ul>


'''To edit previously created scripts'''<br />
1 Click the Start Recording Script icon on the scripting toolbar. The icon turns red, and the Record New Script dialog box opens.<br />
2 Select File &gt; Open on the Record New Script dialog box. The Open dialog box opens.<br />
3 Select the script that you want to edit. The script appears in the scripting box on the Record New Script dialog box.<br />
4 Click Enable Edit. The actions box turns from gray to white.<br />
5 Select any of the actions and copy, rearrange, or delete them, or type new actions directly into the scripting box.<br />
6 Click Disable Edit when you are satisfied with the script. The scripting box returns to gray.<br />
7 Continue recording actions if needed until you are satisfied the script.<br />
8 Save the script by clicking File &gt; Save. The Save dialog box opens.<br />
9 Type the name of the script followed by the ''.sct'' extension in the File Name box.<br />
10 Click Save. MIPAV saves the script under the specified name.<br />


'''To delete scripts (Windows specific)'''
== Videos ==
This video tutorial explains how to load images into MIPAV and change the memory allocation - [http://www.youtube.com/embed/npSYWYJa530 play].


If you decide at some point that you want to delete a script, go to Windows Explorer and navigate to the scripts home directory.
== See also: ==
*[[Getting Started Quickly with MIPAV]]
*[[Allocating Memory in MIPAV]]
*[[Opening and loading image files]]


1 Open Windows explorer.<br />
Next: [[FAQ: Customizing MIPAV]]
2 Navigate to the scripts home directory.<br />
3 Select the script or scripts that you want to delete.<br />
4 Right-click on the selected script(s).<br />
5 Click Delete. Windows deletes the selected scripts and places them in the Recycle Bin where they stay until you empty the bin.<br />


[[Category: Help]]


[[Examples]]
[[Category: FAQ]]

Revision as of 17:32, 18 May 2012

When MIPAV performs a function, such as visualizing an image file, it uses RAM on your computer. When you run MIPAV for the first time you must specify the maximum amount of memory (it calls the maximum heap size in the dialog box) that you would like to allocate for MIPAV, so it can take the full advantage of the memory resources available in your machine. The default value is 1000 MB. The amount of memory you can allocate to MIPAV is limited by how much RAM is installed on your system.

User permissions

MIPAV’s memory allocation is a program-level feature and it affects all users of a given MIPAV installation. You can only change the amount of allocated memory, if you are running MIPAV using an administrative account.

Memory limitations

OS Max memory
Windows 32 1.3 GB
Windows 64 196 TB
Mac OS 196 TB
Linux 32 4 GB
Linux 64 196 TB

Comment: These memory allocations are limited by how much RAM is installed on your computer.

How can I allocate (more) memory for MIPAV?

When you are installing MIPAV

Installing MIPAV: the JVM Memory Limit tab

Starting version 5.4.2 the easiest way to allocate memory in MIPAV is to do it when you are installing MIPAV. You can define the memory value in the JVM Memory Limit pane. The default value is set to 1000 MB. In the Pre-Installation summary pane, you can review memory settings, and then return back to the JVM Memory Limit pane and adjust them, if needed.

In case you figured out later that you need more memory, you can still make adjustments using the Check java-runtime Memory Allocation dialog box options. See instructions provided for different operational systems below.


Windows users: adjusting memory settings

  1. Login to your computer under the administrative account, or under the user account who installed MIPAV.
  2. Select Help » Memory allocation in the Main MIPAV window. The Check java-runtime Memory Allocation dialog box opens.
  3. In the dialog box, change the maximum heap size number so it reflects the maximum amount of memory you might need. Note that for Windows 32, there is a 1.3 GB limit for memory allocation.
  4. The Change java-runtime Memory Allocation dialog box
  5. Click OK to close the dialog box.
  6. You must restart of MIPAV for the changes to take effect. To exit MIPAV, select File » Exit. Then, restart the software.

Now, when more memory is needed to perform a certain task, MIPAV allocates it until the memory reaches the maximum heap size you specified. You can also access this dialog anytime and change the memory allocation parameter as you wish.

Linux users: adjusting memory settings

To change the amount of memory allocated for MIPAV use, you need to run MIPAV using an account that has write-permission to the directory where MIPAV is installed, such as an administrator. The heap size is set in the mipav.lax file located in the directory where MIPAV is installed. E.g. /usr/share/mipav (and not within your own user mipav folder, e.g. ~/mipav). Therefore, you need to run MIPAV with the appropriate permissions to modify files in that directory for the one time when you use the memory allocation tool.

  1. Login to your computer under the administrative account, or under the user account who installed MIPAV.
  2. Select Help » Memory Allocation in the Main MIPAV window. The Check java-runtime Memory Allocation dialog box opens.
  3. In the dialog box, change the maximum heap size number so it reflects the maximum amount of memory you might need.
  4. Click OK to close the dialog box.
  5. You must restart of MIPAV for the changes to take an effect. To exit MIPAV, select File » Exit. Then, restart the software.

Mac OS users: adjusting memory settings

Follow the instructions provided to the Linux users. The only difference is that in Mac OS the mipav.lax file is called mipav.command.lax, but it looks just the same.

mipav.lax file

To adjust memory settings, MIPAV needs an access to the mipav.lax file located in the directory where MIPAV is installed. That’s why you need the appropriate permissions to make changes in this file. See also: MIPAV LAX files.

mipav.lax file: the allocating memory section

LAX.NL.JAVA.OPTION.JAVA.HEAP.SIZE.INITIAL

# -----------------------------------------

# Java start up heap size

lax.nl.java.option.java.heap.size.initial=1048576000

# LAX.NL.JAVA.OPTION.JAVA.HEAP.SIZE.MAX

# -------------------------------------

# Java maximum heap size

lax.nl.java.option.java.heap.size.max=1048576000

Note: For Mac OS mipav.lax file is called mipav.command.lax, but it looks just the same.

Other situations

The MIPAV Options dialog box

If you change the amount of allocated memory (the maximum heap size) and receive the following error message:

"Heap size settings in the environment startup file either do not match those in the Preference file, or are non-existent. Memory Allocation will display so you can ensure this is correct."

And when you set a new number: in the Change java-runtime Memory Allocation dialog box, the following error message appears:

"Error writing to starting options file. No changes were made."

In order to fix that problem:

This is a common message when you have multiple versions of MIPAV installed on your computer and you switch between them. If you don’t want this warning to show up, you can avoid this by un-checking LAX/Preferences memory check option in the mipav.preferences file. This could be done via the MIPAV Options dialog box.

  1. Select Help » Mipav Options in the Main MIPAV window. The MIPAV Options dialog box opens.
  2. In the dialog box, go to the Other tab.
  3. Un-check the LAX/Preferences memory check box.
  4. Click Apply. The change will take place immediately.

How much memory does MIPAV require to run?

MIPAV requires a base of at least 10 Mb of random access memory (RAM). However, to correctly display image files and to quantify the data, you need to allocate more memory, use disk swap space, or install additional memory beyond this base. Each time MIPAV is installed, it always defaults to 100 Mb.

What affects memory requirements?

Memory requirements fluctuate depending on the size and number of image files that are open at the same time. Factors affecting memory requirements are the following: 1) the physical size of image files (i.e., 1.2 Mb); 2) the number of images opened, because working on more than one image file at the same time requires more memory.

Note:Java provides a method called Garbage Collector that clears all unnecessarily reserved memory. Generally, the software does this automatically, when free memory becomes very limited. However, you can run the Garbage Collector at any time to free memory (refer to How can I free memory? ).

How can I determine the amount of additional memory needed?

To determine the amount of additional memory needed:

  1. Multiply the size of the largest image file that you want to process by 10.
  2. Multiply the results by the number of image files that you want to display simultaneously.
  3. Add this amount to the 10-Mb base memory to result in the total amount of memory typically needed.

Example 1: Memory calculation

If an image file is 2 Mb and you only want to display one image file at a time, you must allocate an additional 20 Mb of RAM to the base memory of 10 Mb to result in a memory requirement of 30 Mb.

2 Mb Size of image file x 10


20 Mb Memory required for displaying and processing 1 image file

+

10 Mb Base memory required for running MIPAV


30 Mb Total memory required

Example 2: Memory calculation

If the largest size image file is 2 Mb and you want to display 3 image files simultaneously, multiply 2 Mb by 10. Then multiply that sum by 3. Add that total to the base memory of 10 Mb to yield a memory requirement of 70 Mb.

2 Mb Largest size image file x 10


20 Mb Memory required for displaying 1 image file x 3 Number of images to display and process simultaneously


60 Mb Memory required to display 3 image files

+

10 Mb Base memory required for running MIPAV


70 Mb Total memory required

How can I determine how much memory is currently being used?

The Memory Monitor dialog box

In the main MIPAV window, select Help » Memory Usage (or press Ctrl+M). The Memory Monitor dialog box appears. The dialog box shows how much memory is allocated and the amount of memory that is being used. The graph displays a pictorial representation of the ratio of allocated memory and amount of memory used. It shows the memory usage during the past 3 minutes and 45 seconds.

Note: You can leave this window open if you want to constantly monitor your memory resources.

How can I free memory?

GarbageCollector.jpg As Java-based programs run, they often leave old variables, objects, or constructors in memory. For instance, if you delineate a VOI, the coordinates of the contours may remain in memory even after you close the image. Java provides a method called the garbage collector (or memory recycling) that automatically freeing objects that are no longer referenced by the program and clears all unnecessarily reserved memory. Generally, the software does this automatically when free memory becomes very limited. However, you can run the garbage collector at any time to free memory by clicking the Garbage Collector button.

To free memory, do the following procedure periodically:

  • Click the Garbage Collector button on the main MIPAV window.
  • Select Help » Memory Usage in the main MIPAV window. The Memory Monitor dialog box appears. Click Free Memory. The system clears all unnecessarily reserved memory.


Videos

This video tutorial explains how to load images into MIPAV and change the memory allocation - play.

See also:

Next: FAQ: Customizing MIPAV