Adjusting Java memory parameters for the Android designer

PDF for offline use

Let us know how you feel about this

Translation Quality


0/250

last updated: 2017-06

The default memory parameters that are used when starting the java process for the Android designer might be incompatible with some system configurations.

Starting with Xamarin Studio 5.7.2.7 and Xamarin for Visual Studio 3.9.344 these settings can be customized on a per-project basis.

New Android designer properties and corresponding Java options

The following property names correspond to the indicated java command-line option

  • AndroidDesignerJavaRendererMinMemory -Xms

  • AndroidDesignerJavaRendererMaxMemory -Xmx

  • AndroidDesignerJavaRendererPermSize -XX:MaxPermSize

Visual Studio

  1. Open your solution in Visual Studio.

  2. Select each Android project one-by-one in the Solution Explorer and click Show All Files twice on each project. You can skip projects that do not contain any .axml layout files. This step will ensure that each project directory contains a .csproj.user file.

  3. Quit Visual Studio.

  4. Locate the .csproj.user file for each of the projects from step 2.

  5. Edit each .csproj.user file in a text editor.

  6. Add any or all of the new Android designer memory properties within a <PropertyGroup> element. You can use an existing <PropertyGroup> or create a new one. Here's a complete example .csproj.user file that includes all 3 attributes set to their default values:

    <?xml version="1.0" encoding="utf-8"?>
    <Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
       <PropertyGroup>
         <ProjectView>ProjectFiles</ProjectView>
       </PropertyGroup>
       <PropertyGroup>
         <AndroidDesignerJavaRendererMinMemory>128m</AndroidDesignerJavaRendererMinMemory>
         <AndroidDesignerJavaRendererMaxMemory>750m</AndroidDesignerJavaRendererMaxMemory>
         <AndroidDesignerJavaRendererPermSize>350m</AndroidDesignerJavaRendererPermSize>
       </PropertyGroup>
    </Project>
  7. Save and close all of the updated .csproj.user files.

  8. Restart Visual Studio and reopen your solution.

Xamarin Studio

  1. Open your solution in Xamarin Studio to ensure the solution directory contains a .userprefs file.

  2. Quit Xamarin Studio.

  3. Locate the .userprefs file in the solution directory.

  4. Edit the .userprefs file in a text editor.

  5. Locate the existing XML element with the following format:

    <MonoDevelop.Ide.ItemProperties.AndroidApplication1 ... >

    The last part of this element name will match the name of your project: "AndroidApplication1" in this example.

  6. If the <MonoDevelop.Ide.ItemProperties.AndroidApplication1 ... > element does not exist, create it anywhere within the enclosing <Properties> element. Be sure to replace "AndroidApplication1" with the name of your project.

  7. Add any or all of the new Android designer memory properties as attributes on the element. Here's a complete example .userprefs file that includes all 3 attributes set to their default values:

    <Properties StartupItem="AndroidApplication1\AndroidApplication1.csproj">
      <MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" PreferredExecutionTarget="Android.SelectDevice" />
      <MonoDevelop.Ide.Workbench />
      <MonoDevelop.Ide.DebuggingService.Breakpoints>
        <BreakpointStore />
      </MonoDevelop.Ide.DebuggingService.Breakpoints>
      <MonoDevelop.Ide.DebuggingService.PinnedWatches />
      <MonoDevelop.Ide.ItemProperties.AndroidApplication1 AndroidDesignerJavaRendererMinMemory="128m" AndroidDesignerJavaRendererMaxMemory="750m" AndroidDesignerJavaRendererPermSize="350m" />
    </Properties>
  8. Repeat steps 5-7 for each Android project in the solution that contains any .axml layout files. (That is, add one <MonoDevelop.Ide.ItemProperties.ProjectName> element for each project.)

  9. Save and close the .userprefs file.

  10. Restart Xamarin Studio and reopen your solution.

Xamarin Workbook

If it's not already installed, install the Xamarin Workbooks app first. The workbook file should download automatically, but if it doesn't, just click to start the workbook download manually.