# アロケーターのカスタマイズ

> Customize the allocator types with the Editor or command line.

> **注意**すべてのプラットフォームでこの機能がサポートされているわけではありません。詳細については、[プラットフォーム固有](/engine/6000.0/manual/platform-specific.md)のドキュメントを参照してください。

アロケーターの設定をカスタマイズするには、[エディター UI](#use-the-editor) で設定可能な値を編集するか、[コマンドライン引数](#use-command-line-arguments)として指定します。

## エディターの使用

1. *Project Settings* > *Memory Settings* を選択します。
2. 編集する値の横にあるロックアイコンを選択します。


**Project Settings > Memory Settings を選択して表示される、選択した Player のメモリ設定:**
![](/api/media?file=/engine/6000.0/media/images/Memory_Settings.png)

> **ノート**: エディター UI でカスタマイズ可能なフィールドについては、前述の個々のアロケーターのセクションを参照してください。

## コマンドライン引数の使用

変更するアロケーターのパラメーター名を見つけるには、エディターとプレイヤーが開始時に表示するアロケーター設定のリストを確認します。例えば、主ヒープアロケーターのブロックサイズを変更するには、`-memorysetup-main-allocator-block-size=<new_value>` を使用します。

アロケーターのパラメーター名とデフォルト値:

| **アロケーター**                              |                                                  |                                                                     | **説明**                                                              | **パラメーター名**                                                | **デフォルト値**                          |
| --------------------------------------- | ------------------------------------------------ | ------------------------------------------------------------------- | ------------------------------------------------------------------- | ---------------------------------------------------------- | ----------------------------------- |
| Main Allocators                         |                                                  |                                                                     | Unity がほとんどの割り当てに使用するアロケーター。                                        |                                                            |                                     |
|                                         | Main Allocator                                   |                                                                     | Unity がほとんどの割り当てに使用する主なアロケーター。                                      |                                                            |                                     |
|                                         |                                                  |                                                                     |                                                                     |                                                            |                                     |
|                                         | Main Thread Block Size                           | メインスレッドアロケーター専用のブロックサイズ。                                            | `memorysetup-main-allocator-block-size`                             | `16777216`                                                 |                                     |
|                                         |                                                  |                                                                     |                                                                     |                                                            |                                     |
|                                         | Shared Thread Block Size                         | 共有スレッドアロケーターのブロックサイズ。                                               | `memorysetup-thread-allocator-block-size`                           | `16777216`                                                 |                                     |
|                                         | Gfx Allocator                                    |                                                                     | Unity が Gfx システム関連の CPU 割り当てに使用するアロケーター。                            |                                                            |                                     |
|                                         |                                                  |                                                                     |                                                                     |                                                            |                                     |
|                                         | Main Thread Block Size                           | メインスレッド Gfx アロケーターの専用ブロックサイズ。                                       | `memorysetup-gfx-main-allocator-block-size`                         | `16777216`                                                 |                                     |
|                                         |                                                  |                                                                     |                                                                     |                                                            |                                     |
|                                         | Shared Thread Block Size                         | 共有スレッド Gfx アロケーターのブロックサイズ。                                          | `memorysetup-gfx-thread-allocator-block-size`                       | `16777216`                                                 |                                     |
|                                         |                                                  |                                                                     |                                                                     |                                                            |                                     |
| Other Allocators                        |                                                  |                                                                     |                                                                     |                                                            |                                     |
|                                         |                                                  |                                                                     |                                                                     |                                                            |                                     |
|                                         | File Cache Block Size                            | 断片化を避けるために、ファイルキャッシュには独自のアロケーターがあります。これは、そのブロックサイズです。               | `memorysetup-cache-allocator-block-size`                            | `4194304`                                                  |                                     |
|                                         |                                                  |                                                                     |                                                                     |                                                            |                                     |
|                                         | Type Tree Block Size                             | 多数の小さな割り当てによる断片化を避けるため、Type Tree は独自のアロケーターを持っています。これは、そのブロックサイズです。 | `memorysetup-typetree-allocator-block-size`                         | `2097152`                                                  |                                     |
|                                         |                                                  |                                                                     |                                                                     |                                                            |                                     |
| Shared Bucket Allocator                 |                                                  | メインアロケーター間で共有されるバケットアロケーター。                                         |                                                                     |                                                            |                                     |
|                                         |                                                  |                                                                     |                                                                     |                                                            |                                     |
|                                         | Bucket Allocator Granularity                     | 共有アロケーター内のバケットのステップサイズ。                                             | `memorysetup-bucket-allocator-granularity`                          | `16`                                                       |                                     |
|                                         |                                                  |                                                                     |                                                                     |                                                            |                                     |
|                                         | Bucket Allocator BucketCount                     | バケットサイズの数。                                                          | `memorysetup-bucket-allocator-bucket-count`                         | `8`                                                        |                                     |
|                                         |                                                  |                                                                     |                                                                     |                                                            |                                     |
|                                         | Bucket Allocator Block Size                      | バケットに使用されるメモリブロックのサイズ。                                              | `memorysetup-bucket-allocator-block-size`                           | `Editor: 8388608``Player: 4194304`                         |                                     |
|                                         |                                                  |                                                                     |                                                                     |                                                            |                                     |
|                                         | Bucket Allocator Block Count                     | 割り当てられるブロックの最大数。                                                    | `memorysetup-bucket-allocator-block-count`                          | `Editor: 8``Player: 1`                                     |                                     |
| Fast Per Thread Temporary Allocators    |                                                  |                                                                     | ごく短期間の割り当てを処理するスレッドローカルストレージ (TLS) アロケーター。                          |                                                            |                                     |
|                                         | Main Thread Block Size                           |                                                                     | メインスレッドスタックの初期サイズ。                                                  | `memorysetup-temp-allocator-size-main`                     | `Editor: 16777216``Player: 4194304` |
|                                         | Job Worker Block Size                            |                                                                     | Unity のジョブシステムにおける各ジョブワーカーのサイズ。                                     | `memorysetup-temp-allocator-size-job-worker`               | `E262144`                           |
|                                         | Background Job Worker Block Size                 |                                                                     | 各バックグラウンドワーカーのサイズ。                                                  | `memorysetup-temp-allocator-size-background-worker`        | `32768`                             |
|                                         | Preload Block Size                               |                                                                     | プリロードマネージャのスタックサイズ。                                                 | `memorysetup-temp-allocator-size-preload-manager`          | `Editor: 33554432``Player: 262144`  |
|                                         | Audio Worker Block Size                          |                                                                     | 各オーディオワーカースレッドのスタックサイズ。                                             | `memorysetup-temp-allocator-size-audio-worker`             | `65536`                             |
|                                         | Cloud Worker Block Size                          |                                                                     | クラウドワーカースレッドのスタックサイズ。                                               | `memorysetup-temp-allocator-size-cloud-worker`             | `32768`                             |
|                                         | Gfx Thread Blocksize                             |                                                                     | メインのレンダースレッドのスタックサイズ。                                               | `memorysetup-temp-allocator-size-gfx`                      | `262144`                            |
|                                         | GI Baking Blocksize                              |                                                                     | 各 GI ワーカースレッドのスタックサイズ。                                              | `memorysetup-temp-allocator-size-gi-baking-worker`         | `262144`                            |
|                                         | NavMesh Worker Block Size                        |                                                                     | ナビメッシュワーカースレッドのスタックサイズ。                                             | `memorysetup-temp-allocator-size-nav-mesh-worker`          | `65536`                             |
| Fast Thread Shared Temporary Allocators |                                                  |                                                                     | スレッド間で共有される短期間の割り当てのための高速リニアアロケーター。                                 |                                                            |                                     |
|                                         | Job Allocator Block Size                         |                                                                     | Unity が主にジョブワーカースレッドに使用する、ラウンドロビン方式のリニアスレッドアロケーター。                  | `memorysetup-job-temp-allocator-block-size`                | `2097152`                           |
|                                         | Background Job Allocator Block Size              |                                                                     | バックグラウンドワーカー用のリニアアロケーターで、より長時間の割り当てが可能。                             | `memorysetup-job-temp-allocator-block-size-background`     | `21048576`                          |
|                                         | Job Allocator Block Size on low memory platforms |                                                                     | メモリが 2 GB 未満のプラットフォームでは、ジョブワーカーとバックグラウンドジョブの両方に、このサイズが使用されます。       | `memorysetup-job-temp-allocator-reduction-small-platforms` | `262144`                            |
| Profiler Allocators                     |                                                  |                                                                     | アプリケーションの割り当てパターンに干渉しないように、Unity がプロファイラー専用に使用するアロケーター。             |                                                            |                                     |
|                                         | Profiler Block Size                              |                                                                     | プロファイラーの主要部分のブロックサイズ。                                               | `memorysetup-profiler-allocator-block-size`                | `16777216`                          |
|                                         | Editor Profiler Block Size                       |                                                                     | プロファイラーのエディター部分のブロックサイズ。これはプレイヤーには存在しません。                           | `memorysetup-profiler-editor-allocator-block-size`         | `1048576`                           |
|                                         | Shared Profiler Bucket Allocator                 |                                                                     | プロファイラーとエディタープロファイラーのアロケーター用の、共有バケットアロケーター。ローメモリのプラットフォームでは使用できません。 |                                                            |                                     |
|                                         |                                                  |                                                                     |                                                                     |                                                            |                                     |
|                                         | Bucket Allocator Granularity                     | 共有アロケーター内のバケットのステップサイズ。                                             | `memorysetup-profiler-bucket-allocator-granularity`                 | `16`                                                       |                                     |
|                                         |                                                  |                                                                     |                                                                     |                                                            |                                     |
|                                         | Bucket Allocator BucketCount                     | バケットサイズの数。例えば、値が 4 の場合、サイズは 16、32、48、64 です。                         | `memorysetup-profiler-bucket-allocator-bucket-count`                | `8`                                                        |                                     |
|                                         |                                                  |                                                                     |                                                                     |                                                            |                                     |
|                                         | Bucket Allocator Block Size                      | バケットに使用されるメモリブロックのサイズ。                                              | `memorysetup-profiler-bucket-allocator-block-size`                  | `Editor: 33554432``Player: 4194304`                        |                                     |
|                                         |                                                  |                                                                     |                                                                     |                                                            |                                     |
|                                         | Bucket Allocator Block Count                     | 割り当てられるブロックの最大数。                                                    | `memorysetup-profiler-bucket-allocator-block-count`                 | `Editor: 8``Player: 1`                                     |                                     |

> **ヒント**: 設定によるパフォーマンスの改善を確認するには、変更の前後でアプリケーションのプロファイルを作成します。詳細は、[プロファイルの概要ページ](/engine/6000.0/manual/analysis/profiler.md)、 および [Profiler Analyzer](https://docs.unity3d.com/Packages/com.unity.performance.profile-analyzer@latest) のパッケージドキュメントを参照してください。Profiler Analyzer によりマルチフレームの比較ができます。これは、アロケーターのパフォーマンスにおける違いを明確にするのに役立ちます。メモリ使用状況レポートを確認することもできます。プレイヤーまたはエディターを閉じるとログに表示されます。ログファイルを見つけるには、[ログファイルページ](/engine/6000.0/manual/scripting/debugging-and-diagnostics/log-files.md)の指示に従います。

## 設定の保存と読み取り

Unity はアロケーターの設定を `MemorySettings.asset` に保存します。これにより、変更された設定がビルド時に `boot.config` ファイルに入力されます。これは、新しい設定はビルドごとに有効になることを意味します。

エディターでは、`boot.config` は `ProjectSettings` フォルダーにあり、Unity が `MemorySettings.asset` をインポートまたは変更するたびに更新されます。エディターの新しい値は、次回にエディターを起動したときのみ反映されます。
