{
  "schemaVersion": "0.11.0",
  "canonical": "https://www.pystone.net/notes/uwa-answer-unity-and-dotnet-garbage-collection/",
  "atlas": "https://www.pystone.net/?node=uwa-answer-unity-and-dotnet-garbage-collection#knowledge-atlas",
  "markdown": "https://www.pystone.net/notes/uwa-answer-unity-and-dotnet-garbage-collection.md",
  "context": "https://www.pystone.net/notes/uwa-answer-unity-and-dotnet-garbage-collection.context.json",
  "knowledgeVersion": "224c990773de.5fa8af6e39fa",
  "build": {
    "siteCommit": "224c990773de166d23a886306577dd90379529ce",
    "notesCommit": "5fa8af6e39fa3891d1b9b4832bfa6c4e0ecaaf0a",
    "builtAt": "1970-01-01T00:00:00.000Z",
    "version": "224c990773de.5fa8af6e39fa"
  },
  "id": "note:uwa-answer-unity-and-dotnet-garbage-collection",
  "slug": "uwa-answer-unity-and-dotnet-garbage-collection",
  "title": "unity自身GC和.net的GC如何协调工作的",
  "type": "note",
  "visibility": "public",
  "idStability": "rename-stable",
  "author": {
    "name": "石心.Yong"
  },
  "publisher": {
    "name": "Perrin Yong",
    "profile": "https://www.pystone.net/profile/"
  },
  "aliases": [],
  "summary": "unity自身GC和.net的GC如何协调工作的",
  "contentRole": "source",
  "sourceType": "source",
  "sourceMetadata": {
    "author": "石心.Yong"
  },
  "isMoc": false,
  "mocRecognition": "none",
  "generated": false,
  "attribution": "external_source",
  "domain": "10-计算机、信息技术与工程",
  "tags": [],
  "mocs": [],
  "contentHash": "1d6651ae731bdecb0c43ff5994f33978ae7840cbccc06a80b50e2d2514079e85",
  "assets": [
    {
      "reference": "assets/5eda0243eab6db1f8238a372/01.png",
      "url": "/media/923654293893a7cf78a3.png",
      "mediaType": "image/png",
      "contentHash": "923654293893a7cf78a35b43c8e3552f2ddabdf80dd9627c1b067f1d656ce011",
      "byteLength": 74883,
      "width": 480,
      "height": 554
    },
    {
      "reference": "assets/5eda0243eab6db1f8238a372/02.png",
      "url": "/media/de4dba67a1bf3a63a36b.png",
      "mediaType": "image/png",
      "contentHash": "de4dba67a1bf3a63a36bb4250ea900d815d4a223eb71feadce4f888b64cd7890",
      "byteLength": 22369,
      "width": 603,
      "height": 446
    },
    {
      "reference": "assets/5eda0243eab6db1f8238a372/03.png",
      "url": "/media/bad4735cbcdbbba89933.png",
      "mediaType": "image/png",
      "contentHash": "bad4735cbcdbbba89933e9a80dee1395e6b1e94c5cf04843c070570ba1d3cc43",
      "byteLength": 36596,
      "width": 917,
      "height": 496
    }
  ],
  "headings": [
    {
      "depth": 1,
      "text": "unity自身GC和.net的GC如何协调工作的",
      "anchor": "unity自身gc和net的gc如何协调工作的",
      "citation": "https://www.pystone.net/notes/uwa-answer-unity-and-dotnet-garbage-collection/#unity%E8%87%AA%E8%BA%ABgc%E5%92%8Cnet%E7%9A%84gc%E5%A6%82%E4%BD%95%E5%8D%8F%E8%B0%83%E5%B7%A5%E4%BD%9C%E7%9A%84"
    },
    {
      "depth": 2,
      "text": "问题",
      "anchor": "问题",
      "citation": "https://www.pystone.net/notes/uwa-answer-unity-and-dotnet-garbage-collection/#%E9%97%AE%E9%A2%98"
    },
    {
      "depth": 2,
      "text": "我的回答",
      "anchor": "我的回答",
      "citation": "https://www.pystone.net/notes/uwa-answer-unity-and-dotnet-garbage-collection/#%E6%88%91%E7%9A%84%E5%9B%9E%E7%AD%94"
    },
    {
      "depth": 2,
      "text": "来源与关系",
      "anchor": "来源与关系",
      "citation": "https://www.pystone.net/notes/uwa-answer-unity-and-dotnet-garbage-collection/#%E6%9D%A5%E6%BA%90%E4%B8%8E%E5%85%B3%E7%B3%BB"
    }
  ],
  "claims": [],
  "outgoing": [
    {
      "id": "note:my-uwa-answers",
      "title": "我的 UWA 问答",
      "url": "https://www.pystone.net/notes/my-uwa-answers/",
      "atlas": "https://www.pystone.net/?node=my-uwa-answers#knowledge-atlas",
      "label": "我的 UWA 问答",
      "origin": "explicit",
      "humanReviewed": true,
      "context": "上位集合：我的 UWA 问答",
      "citation": "https://www.pystone.net/notes/uwa-answer-unity-and-dotnet-garbage-collection/#%E6%9D%A5%E6%BA%90%E4%B8%8E%E5%85%B3%E7%B3%BB"
    }
  ],
  "incoming": [
    {
      "id": "note:my-uwa-answers",
      "title": "我的 UWA 问答",
      "url": "https://www.pystone.net/notes/my-uwa-answers/",
      "atlas": "https://www.pystone.net/?node=my-uwa-answers#knowledge-atlas",
      "label": "我的 UWA 问答",
      "origin": "explicit",
      "humanReviewed": true,
      "context": "2020-06-13：unity自身GC和.net的GC如何协调工作的（内存管理）",
      "citation": "https://www.pystone.net/notes/my-uwa-answers/#2020"
    },
    {
      "id": "note:game-graphics-and-runtime",
      "title": "游戏图形与运行时",
      "url": "https://www.pystone.net/notes/game-graphics-and-runtime/",
      "atlas": "https://www.pystone.net/?node=game-graphics-and-runtime#knowledge-atlas",
      "label": "游戏图形与运行时",
      "origin": "explicit",
      "humanReviewed": true,
      "context": "我的UWA问答中的“2020-06-13 - unity自身GC和.net的GC如何协调工作的”导航项",
      "citation": "https://www.pystone.net/notes/game-graphics-and-runtime/#%E6%88%91%E7%9A%84uwa%E9%97%AE%E7%AD%94"
    }
  ],
  "contentMarkdown": "# unity自身GC和.net的GC如何协调工作的\n\n> [!note] 我的 UWA 问答\n> 本文收录我在 UWA 问答发表的公开回答。问题内容归原提问者；回答保留当时语境，技术结论可能受 Unity 版本、平台和项目条件限制。\n\n## 问题\n\nunity有自己的GC，.net也有自己的GC，两者在游戏运行的时候，是如何协调工作的？\n\n- 提问者：徐冠\n- 提问时间：2020-06-06 00:28:51\n\n## 我的回答\n\n提出这个问题之前，先要搞清楚一个问题: Unity与Mono和.NET三个概念之间的的关系\n\n维基百科：\n\n.NET框架（英語：.NET Framework）是由微软开发，一个致力于敏捷软件开发（agile software development）、快速应用开发（rapid application development）、平台无关性和网络透明化的软件框架。\n\n嗯，.NET Framework是一个软件框架，可以理解为对一系列结构和功能的期待。不是一个具体的某个软件。 最初有一段时间，.NET框架只能在windows平台上运行。\n\n.NET架构代码的编译运行过程如下：\n\n![480pxOverview_of_the_Common_Language_Infrastructure.svg.png](assets/5eda0243eab6db1f8238a372/01.png)\n\nMono是.NET运行时和开发库的实现版本，为C#脚本提供一个编译器和运行的虚拟机（CLR）。Mono的初衷是：(1)使微软.NET应用可以跨平台运行 (2)支持.NET在Linux上使用。Mono比.NET Core支持更多的平台（如Linux, FreeBSD, Unix, Mac OS X和Solaris）。\n\nUnity引擎对跨平台特性有很大的需求，于是使用Mono提供c#等符合CLI规范的脚本语言的运行环境。\n\n直观的理解参考下图：\n\n![.NET.png](assets/5eda0243eab6db1f8238a372/02.png)\n\n![Unity.png](assets/5eda0243eab6db1f8238a372/03.png)\n\n总的来说，Unity驱动Mono，为C#等提供编译和运行的环境。而C#等脚本的GC便是由Mono的虚拟机提供的。\n\n因此，题主说的Unity自己的GC，和.NET的GC，应该是一回事，也就是Mono的GC。\n\n（如有错误之处，希望大神指出）\n\nRef:\n\nhttps://www.cnblogs.com/shanyou/p/4295163.html\n\nhttps://www.cnblogs.com/zhujinghui/p/3369217.html\n\nhttps://zh.wikipedia.org/wiki/.NET%E6%A1%86%E6%9E%B6\n\nhttps://en.wikipedia.org/wiki/Mono_(software)\n\nhttps://www.cnblogs.com/u3ddjw/p/10909975.html\n\nhttps://www.cnblogs.com/u3ddjw/p/10909975.html\n\n- 回答时间：2020-06-13 05:48:02\n- 最后更新：2020-06-13 08:53:48\n- 采纳状态：未采纳\n\n## 来源与关系\n\n- 上位集合：[[10-计算机、信息技术与工程/05-游戏图形与运行时/我的UWA问答/我的UWA问答|我的 UWA 问答]]\n- UWA 标签：内存管理\n- 原始问题：[unity自身GC和.net的GC如何协调工作的](https://answer.uwa4d.com/question/5eda0243eab6db1f8238a372)\n- 源页最后更新：2020-06-17 20:53:50\n"
}
