<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>potisan</author_name>
  <author_url>https://blog.hatena.ne.jp/potisan/</author_url>
  <blog_title>potisanのプログラミングメモ</blog_title>
  <blog_url>https://potisan-programming-memo.hatenablog.jp/</blog_url>
  <categories>
    <anon>C#</anon>
  </categories>
  <description>C#には弱い参照を表すSystem.WeakReference&lt;T&gt;があり、あるメモリの管理をGCに任せたい場合に使用されます。自身の環境（Windows 11 Home）でメモリ確保量に合わせて適切に解放されるか確認するコードを作成したので、そのまま記載します。 手元の出力結果は「2/4」で、4回目のメモリ確保で最初2回分は一気に解放されて最後2回分は解放されず生き残りました。今回は整数型配列で試していますが、COMオブジェクト等をWeakReference&lt;T&gt;で持つことも（具体的なサイズが分からないことやWeakReference&lt;T&gt;のコストの方が大きい可能性を無視すれば）選択肢かもし…</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Fpotisan-programming-memo.hatenablog.jp%2Fentry%2F2026%2F02%2F11%2F063818&quot; title=&quot;C# 弱い参照WeakReference&amp;lt;T&amp;gt;の動作確認コード - potisanのプログラミングメモ&quot; class=&quot;embed-card embed-blogcard&quot; scrolling=&quot;no&quot; frameborder=&quot;0&quot; style=&quot;display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;&quot;&gt;&lt;/iframe&gt;</html>
  <image_url></image_url>
  <provider_name>Hatena Blog</provider_name>
  <provider_url>https://hatena.blog</provider_url>
  <published>2026-02-11 06:38:18</published>
  <title>C# 弱い参照WeakReference&lt;T&gt;の動作確認コード</title>
  <type>rich</type>
  <url>https://potisan-programming-memo.hatenablog.jp/entry/2026/02/11/063818</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
