<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:media="http://search.yahoo.com/mrss/"><channel><title><![CDATA[lichen]]></title><description><![CDATA[Thoughts, stories and ideas.]]></description><link>http://www.lichen.in/</link><image><url>http://www.lichen.in/favicon.png</url><title>lichen</title><link>http://www.lichen.in/</link></image><generator>Ghost 5.85</generator><lastBuildDate>Sun, 10 May 2026 15:41:31 GMT</lastBuildDate><atom:link href="http://www.lichen.in/rss/" rel="self" type="application/rss+xml"/><ttl>60</ttl><item><title><![CDATA[Using HikariCP integrate Clickhouse in SpringBoot]]></title><description><![CDATA[<p>What is &quot;HikariCP&quot;?</p><p>&#x5149; HikariCP&#x30FB;A solid, high-performance, JDBC connection pool at last. in short, it&apos;s library for JDBC connection pool, it make you easier manage your &#xA0;JDBC connection pool.</p><p>Using HikariCP integrate Clickhouse, there are three steps.</p><ol><li>config Clickhouse datasource url/username/password</li></ol>]]></description><link>http://www.lichen.in/using/</link><guid isPermaLink="false">62d6c4373fab384365b11c38</guid><dc:creator><![CDATA[lichen]]></dc:creator><pubDate>Fri, 25 Aug 2023 20:39:21 GMT</pubDate><content:encoded><![CDATA[<p>What is &quot;HikariCP&quot;?</p><p>&#x5149; HikariCP&#x30FB;A solid, high-performance, JDBC connection pool at last. in short, it&apos;s library for JDBC connection pool, it make you easier manage your &#xA0;JDBC connection pool.</p><p>Using HikariCP integrate Clickhouse, there are three steps.</p><ol><li>config Clickhouse datasource url/username/password on the yml file, it also set this information on Vault, it depends on you.</li><li>create the config class on SpringBoot, this class will read Clickhouse configuration on yml file, and establish connection.</li><li>this step is optional, create JdbcTemplate, it is easy for query clickhouse</li></ol><h2 id="first-step">First step</h2><p>config yml file</p><pre><code class="language-yml">spring:
  datasource:
    clickhouse:type: com.zaxxer.hikari.HikariDataSource
    driver-class-name: com.clickhouse.jdbc.ClickHouseDriver
    jdbc-url: jdbc:clickhouse://xxxxx
    username: abc
    password: abc</code></pre><p></p><h2 id="second-step">Second step</h2><p>create config class</p><pre><code class="language-kotlin">@Configuration
class ClickHouseDataSourceConfig {
    @Bean
    @ConfigurationProperties(prefix = &quot;spring.datasource.clickhouse&quot;)
    fun clickhouseDataSource(
            @Value(&quot;${spring.datasource.clickhouse.username}&quot;) username: String,
            @Value(&quot;${spring.datasource.clickhouse.password}&quot;) password: String
    ): DataSource = DataSourceBuilder.create().type(HikariDataSource::class.java).build().apply {
        this.username = username
        this.password = password
        this.isReadOnly = true
    }
    
    @Bean(&quot;clickhouseJdbcTemplate&quot;) //create JdbcTemplate,optional
    fun clickhouseJdbcTemplate(@Qualifier(&quot;clickhouseDataSource&quot;) dataSource: DataSource): JdbcTemplate =
        JdbcTemplate(dataSource)
}</code></pre><p></p><p>that&apos;s all</p>]]></content:encoded></item><item><title><![CDATA[在Spring中使用HikariCP集成Clickhouse]]></title><description><![CDATA[<p>&#x4EC0;&#x4E48;&#x662F;HikariCP?</p><p>&#x5149; HikariCP&#x30FB;A solid, high-performance, JDBC connection pool at last. &#x7B80;&#x5355;&#x7684;&#x8BF4;,&#x5C31;&#x662F;&#x4E00;&#x4E2A;JDBC&#x7684;&#x8FDE;&#x63A5;&#x6C60;&#x7684;&#x5E93;,&#x5982;&#x679C;&#x60F3;&#x8F7B;&#x677E;&#x7684;&#x7BA1;&#x7406;&#x8FDE;&#x63A5;&#x6C60;,&#x4F7F;&#x7528;&#x5B83;&#x80AF;&#x5B9A;&#x662F;&#x6CA1;&#x9519;&#x7684;</p>]]></description><link>http://www.lichen.in/shi-yong-hikaricpji-cheng-clickhouse/</link><guid isPermaLink="false">62d6b8543fab384365b11bdb</guid><dc:creator><![CDATA[lichen]]></dc:creator><pubDate>Fri, 25 Aug 2023 20:39:07 GMT</pubDate><media:content url="http://www.lichen.in/content/images/2022/07/1_AbiX4LwtSNozoyfypcKvEg.png" medium="image"/><content:encoded><![CDATA[<img src="http://www.lichen.in/content/images/2022/07/1_AbiX4LwtSNozoyfypcKvEg.png" alt="&#x5728;Spring&#x4E2D;&#x4F7F;&#x7528;HikariCP&#x96C6;&#x6210;Clickhouse"><p>&#x4EC0;&#x4E48;&#x662F;HikariCP?</p><p>&#x5149; HikariCP&#x30FB;A solid, high-performance, JDBC connection pool at last. &#x7B80;&#x5355;&#x7684;&#x8BF4;,&#x5C31;&#x662F;&#x4E00;&#x4E2A;JDBC&#x7684;&#x8FDE;&#x63A5;&#x6C60;&#x7684;&#x5E93;,&#x5982;&#x679C;&#x60F3;&#x8F7B;&#x677E;&#x7684;&#x7BA1;&#x7406;&#x8FDE;&#x63A5;&#x6C60;,&#x4F7F;&#x7528;&#x5B83;&#x80AF;&#x5B9A;&#x662F;&#x6CA1;&#x9519;&#x7684;.</p><p></p><p>&#x4F7F;&#x7528;HikariCP&#x96C6;&#x6210;Clickhouse,&#x5927;&#x81F4;&#x5206;&#x4E3A;&#x4E09;&#x6B65;</p><ol><li>&#x5728;yml&#x6587;&#x4EF6;&#x914D;&#x7F6E;clickhouse&#x7684;url,&#x7528;&#x6237;&#x540D;&#x5BC6;&#x7801;,&#x4E5F;&#x53EF;&#x4EE5;&#x5C06;&#x8FD9;&#x4E9B;&#x914D;&#x7F6E;&#x5230;vault&#x4E0A;,&#x8FD9;&#x4E2A;&#x53D6;&#x51B3;&#x4F60;.</li><li>&#x521B;&#x5EFA;&#x5BF9;&#x5E94;&#x7684;config class, &#x8BFB;&#x53D6;yml&#x6587;&#x4EF6;&#x914D;&#x7F6E;</li><li>&#x521B;&#x5EFA;&#x5BF9;&#x5E94;&#x7684;JdbcTemplate(optional)</li></ol><h2 id="%E7%AC%AC%E4%B8%80%E6%AD%A5">&#x7B2C;&#x4E00;&#x6B65;</h2><p>&#x914D;&#x7F6E;yml&#x6587;&#x4EF6;:</p><pre><code class="language-yml">spring:
  datasource:
    clickhouse:type: com.zaxxer.hikari.HikariDataSource
    driver-class-name: com.clickhouse.jdbc.ClickHouseDriver
    jdbc-url: jdbc:clickhouse://xxxxx
    username: abc
    password: abc</code></pre><p></p><h2 id="%E7%AC%AC%E4%BA%8C%E6%AD%A5">&#x7B2C;&#x4E8C;&#x6B65;</h2><p>&#x521B;&#x5EFA;&#x5BF9;&#x5E94;&#x7684;config class.</p><pre><code class="language-kotlin">@Configuration
class ClickHouseDataSourceConfig {
    @Bean
    @ConfigurationProperties(prefix = &quot;spring.datasource.clickhouse&quot;)
    fun clickhouseDataSource(
            @Value(&quot;${spring.datasource.clickhouse.username}&quot;) username: String,
            @Value(&quot;${spring.datasource.clickhouse.password}&quot;) password: String
    ): DataSource = DataSourceBuilder.create().type(HikariDataSource::class.java).build().apply {
        this.username = username
        this.password = password
        this.isReadOnly = true
    }
    
    @Bean(&quot;clickhouseJdbcTemplate&quot;) //&#x914D;&#x7F6E;JdbcTemplate,optional
    fun clickhouseJdbcTemplate(@Qualifier(&quot;clickhouseDataSource&quot;) dataSource: DataSource): JdbcTemplate =
        JdbcTemplate(dataSource)
}</code></pre><p>&#x81F3;&#x6B64;&#x96C6;&#x6210;clickhouse&#x5C31;&#x7ED3;&#x675F;&#x5566;.</p>]]></content:encoded></item><item><title><![CDATA[Chromium for android 编译注意事项]]></title><description><![CDATA[<!--kg-card-begin: markdown--><ol>
<li>&#x7F16;&#x8BD1;Chromium&#x65F6;&#x9ED8;&#x8BA4;&#x662F;&#x4E0D;&#x652F;&#x6301;MP3,MP4&#x683C;&#x5F0F;&#x7684;,&#x6240;&#x4EE5;&#x7F16;&#x8BD1;&#x51FA;&#x6765;&#x7684;&#x7248;&#x672C;&#x662F;&#x65E0;&#x6CD5;&#x64AD;&#x653E;&#x97F3;&#x9891;&#x548C;&#x89C6;&#x9891;&#x7684;,&#x5982;&#x679C;&#x8981;&#x64AD;&#x653E;&#x65F6;,&#x5C31;&#x4F1A;&#x4EA7;&#x751F;&#x8FD9;&#x6837;&#x7684;error log:</li></ol>]]></description><link>http://www.lichen.in/chromium-for-android-bian-yi-zhu-yi-shi-xiang/</link><guid isPermaLink="false">5b860947b85082062628dd92</guid><dc:creator><![CDATA[lichen]]></dc:creator><pubDate>Fri, 25 Aug 2023 20:38:54 GMT</pubDate><media:content url="http://www.lichen.in/content/images/2018/08/chromium-logo-100751561-large.jpg" medium="image"/><content:encoded><![CDATA[<!--kg-card-begin: markdown--><ol>
<li>&#x7F16;&#x8BD1;Chromium&#x65F6;&#x9ED8;&#x8BA4;&#x662F;&#x4E0D;&#x652F;&#x6301;MP3,MP4&#x683C;&#x5F0F;&#x7684;,&#x6240;&#x4EE5;&#x7F16;&#x8BD1;&#x51FA;&#x6765;&#x7684;&#x7248;&#x672C;&#x662F;&#x65E0;&#x6CD5;&#x64AD;&#x653E;&#x97F3;&#x9891;&#x548C;&#x89C6;&#x9891;&#x7684;,&#x5982;&#x679C;&#x8981;&#x64AD;&#x653E;&#x65F6;,&#x5C31;&#x4F1A;&#x4EA7;&#x751F;&#x8FD9;&#x6837;&#x7684;error log:</li>
</ol>
<pre><code>PIPELINE_ERROR DEMUXER_ERROR_NO_SUPPORTED_STREAM
</code></pre>
<img src="http://www.lichen.in/content/images/2018/08/chromium-logo-100751561-large.jpg" alt="Chromium for android &#x7F16;&#x8BD1;&#x6CE8;&#x610F;&#x4E8B;&#x9879;"><p>&#x5982;&#x679C;&#x9700;&#x8981;&#x5BF9;&#x97F3;&#x89C6;&#x9891;&#x8FDB;&#x884C;&#x652F;&#x6301;&#x7684;&#x8BDD;,&#x9700;&#x8981;&#x5728;args.gn&#x6587;&#x4EF6;&#x4E2D;,&#x589E;&#x52A0;&#x5982;&#x4E0B;&#x7684;&#x914D;&#x7F6E;:</p>
<pre><code>proprietary_codecs = true
ffmpeg_branding = &quot;Chrome&quot;
</code></pre>
<p>&#x8FD9;&#x6837;&#x91CD;&#x65B0;&#x7F16;&#x8BD1;&#x4E4B;&#x540E;&#x5C31;&#x53EF;&#x4EE5;&#x64AD;&#x653E;&#x89C6;&#x9891;&#x4E86;.<br>
google group&#x8BA8;&#x8BBA;&#x533A;&#x539F;&#x8D34;<a href="https://groups.google.com/a/chromium.org/forum/?ref=lichen.in#!topic/android-webview-dev/oVjyFhhxOQ8">Does anyone know how Chrome for Android or Android Webview plays facebooks videos?</a></p>
<ol start="2">
<li>&#x7F16;&#x8BD1;&#x9519;&#x8BEF;transport_security_state_generator failed with exit code -11,&#x5BFC;&#x81F4;&#x65E0;&#x6CD5;&#x751F;&#x6210;out/Default/gen/net/http/transport_security_state_static.h,&#x8FD9;&#x4E2A;&#x95EE;&#x9898;&#x5E94;&#x8BE5;&#x662F;&#x5F53;&#x524D;&#x4F7F;&#x7528;gn_run_binary.py&#x65F6;,&#x6CA1;&#x6709;&#x6743;&#x9650;&#x5BFC;&#x81F4;&#x7684;.&#x53EF;&#x4EE5;&#x81EA;&#x5DF1;&#x624B;&#x52A8;&#x589E;&#x52A0;sudo&#x6743;&#x9650;&#x751F;&#x6210;&#x8BE5;.h&#x6587;&#x4EF6;.</li>
</ol>
<pre><code>sudo transport_security_state_generator json&#x6587;&#x4EF6; pins&#x6587;&#x4EF6; template&#x6587;&#x4EF6; gen/net/http/transport_security_state_static.h 
</code></pre>
<p>&#x8FD9;&#x65F6;&#x5982;&#x679C;&#x6CA1;&#x6709;&#x51FA;&#x73B0;&#x62A5;&#x9519;,&#x5219;&#x6253;&#x5F00;gn_run_binary.py,&#x5C06;&#x4E0B;&#x9762;&#x7684;&#x8FD9;&#x90E8;&#x5206;&#x4EE3;&#x7801;&#x6CE8;&#x91CA;&#x6389;.</p>
<pre><code>if ret != 0:
  print &apos;%s failed with exit code %d&apos; % (sys.argv[1], ret)
sys.exit(ret)
</code></pre>
<p>&#x6700;&#x540E;&#x5219;&#x7EE7;&#x7EED;&#x4F7F;&#x7528;<code>ninja -C out/Default chrome_public_apk</code>&#x7F16;&#x8BD1;.<br>
&#x7F16;&#x8BD1;&#x5B8C;&#x6210;</p>
<p>3.chromium &#x5E38;&#x7528;&#x7F16;&#x8BD1;&#x9009;&#x9879;</p>
<pre><code>target_os = &quot;android&quot;
target_cpu = &quot;arm64&quot;
is_debug = true
dcheck_always_on = false
ffmpeg_branding=&quot;Chrome&quot;
proprietary_codecs = true
is_component_build=false
is_clang=true
</code></pre>
<!--kg-card-end: markdown-->]]></content:encoded></item><item><title><![CDATA[windows subsystem for linux 无法打开32位程序的问题解决]]></title><description><![CDATA[<p>&#x5F53;&#x4F60;&#x5C1D;&#x8BD5;&#x5728;WSL&#x4E0A;&#x8FD0;&#x884C;32&#x4F4D;&#x7684;&#x7A0B;&#x5E8F;&#x65F6;&#xFF0C;shell&#x5C06;&#x4F1A;&#x62A5;&#x9519;&#xFF1A;cannot execute binary file: Exec format error. &#x8FD9;&#x662F;&#x56E0;&#x4E3A;WSL&#x76EE;&#x524D;&#x6682;&#x4E0D;&#x652F;&#x6301;32&#x4F4D;&#x7684;ELF&#x53EF;&#x6267;&#x884C;&#x6587;&#x4EF6;&#x3002;</p>]]></description><link>http://www.lichen.in/windows-sub/</link><guid isPermaLink="false">61cc01203fab384365b11b9d</guid><dc:creator><![CDATA[lichen]]></dc:creator><pubDate>Fri, 25 Aug 2023 20:38:42 GMT</pubDate><content:encoded><![CDATA[<p>&#x5F53;&#x4F60;&#x5C1D;&#x8BD5;&#x5728;WSL&#x4E0A;&#x8FD0;&#x884C;32&#x4F4D;&#x7684;&#x7A0B;&#x5E8F;&#x65F6;&#xFF0C;shell&#x5C06;&#x4F1A;&#x62A5;&#x9519;&#xFF1A;cannot execute binary file: Exec format error. &#x8FD9;&#x662F;&#x56E0;&#x4E3A;WSL&#x76EE;&#x524D;&#x6682;&#x4E0D;&#x652F;&#x6301;32&#x4F4D;&#x7684;ELF&#x53EF;&#x6267;&#x884C;&#x6587;&#x4EF6;&#x3002;</p><p>&#x5728;&#x547D;&#x4EE4;&#x884C;&#x4E2D;&#x52A0;&#x5165;&#x4E0B;&#x9762;&#x4EE3;&#x7801;&#x5C31;&#x53EF;&#x4EE5;&#x4E86;</p><pre><code>sudo apt install qemu-user-static
sudo update-binfmts --install i386 /usr/bin/qemu-i386-static --magic &apos;\x7fELF\x01\x01\x01\x03\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\x03\x00\x01\x00\x00\x00&apos; --mask &apos;\xff\xff\xff\xff\xff\xff\xff\xfc\xff\xff\xff\xff\xff\xff\xff\xff\xf8\xff\xff\xff\xff\xff\xff\xff&apos;
sudo service binfmt-support start</code></pre>]]></content:encoded></item><item><title><![CDATA[V8垃圾回收分析]]></title><description><![CDATA[<!--kg-card-begin: markdown--><h1 id="v8">V8&#x5783;&#x573E;&#x56DE;&#x6536;&#x5206;&#x6790;</h1>
<h2 id>&#x5173;&#x4E8E;&#x5783;&#x573E;&#x56DE;&#x6536;&#x673A;&#x5236;</h2>
<p>&#x7531;&#x4E8E;JavaScript &#x7684;&#x5BF9;&#x8C61;&#x662F;&#x5728;V8&#x4E0A;&#x751F;&#x4EA7;&#x7684;&#xFF0C;&#x6240;&#x4EE5;&#x751F;&#x547D;&#x5468;&#x671F;&#x4E5F;&#x662F;&#x7531;V8&#x6765;&#x63A7;&#x5236;&#xFF0C;&#x8FD9;&#x91CC;&#x5C31;&#x7275;&#x626F;&#x5230;&#x4E86;</p>]]></description><link>http://www.lichen.in/v8la-ji-hui-shou-fen-xi/</link><guid isPermaLink="false">5e7c209ecc408e08c838a1e8</guid><dc:creator><![CDATA[lichen]]></dc:creator><pubDate>Fri, 25 Aug 2023 20:38:32 GMT</pubDate><content:encoded><![CDATA[<!--kg-card-begin: markdown--><h1 id="v8">V8&#x5783;&#x573E;&#x56DE;&#x6536;&#x5206;&#x6790;</h1>
<h2 id>&#x5173;&#x4E8E;&#x5783;&#x573E;&#x56DE;&#x6536;&#x673A;&#x5236;</h2>
<p>&#x7531;&#x4E8E;JavaScript &#x7684;&#x5BF9;&#x8C61;&#x662F;&#x5728;V8&#x4E0A;&#x751F;&#x4EA7;&#x7684;&#xFF0C;&#x6240;&#x4EE5;&#x751F;&#x547D;&#x5468;&#x671F;&#x4E5F;&#x662F;&#x7531;V8&#x6765;&#x63A7;&#x5236;&#xFF0C;&#x8FD9;&#x91CC;&#x5C31;&#x7275;&#x626F;&#x5230;&#x4E86;&#x5783;&#x573E;&#x56DE;&#x6536;&#x3002;&#x4EFB;&#x4F55;&#x5783;&#x573E;&#x56DE;&#x6536;&#x90FD;&#x4F1A;&#x505A;&#x4EE5;&#x4E0B;&#x4E09;&#x4EF6;&#x4E8B;&#x60C5;&#xFF1A;</p>
<ul>
<li>&#x8BC6;&#x522B;&#x4E0D;&#x518D;&#x88AB;&#x5F15;&#x7528;&#x7684;&#x5BF9;&#x8C61;&#xFF08;Dead Objects&#xFF09;</li>
<li>&#x56DE;&#x6536;&#x8FD9;&#x4E9B;&#x5BF9;&#x8C61;&#x6240;&#x5360;&#x7528;&#x7684;&#x5185;&#x5B58;</li>
<li>&#x91CD;&#x65B0;&#x538B;&#x788E;&#x6574;&#x7406;&#x788E;&#x7247;&#x5316;&#x7684;&#x5185;&#x5B58;&#x5757;&#xFF08;&#x53EF;&#x9009;&#x7684;&#xFF09;</li>
</ul>
<h2 id>&#x5206;&#x4EE3;&#x673A;&#x5236;</h2>
<p>V8&#x7684;&#x5783;&#x573E;&#x56DE;&#x6536;&#x673A;&#x5236;&#x4E5F;&#x4E0E;&#x5176;&#x4ED6;&#x4E3B;&#x6D41;&#x8BED;&#x8A00;&#x4E00;&#x6837;&#xFF08;&#x6709;&#x5783;&#x573E;&#x56DE;&#x6536;&#x673A;&#x5236;&#x7684;&#x8BED;&#x8A00;&#xFF09;&#xFF0C;&#x4F7F;&#x7528;&#x7684;&#x4E16;&#x4EE3;&#x56DE;&#x6536;&#x673A;&#x5236;&#xFF0C;&#x4E3B;&#x8981;&#x6709;&#x4E24;&#x4E2A;&#x4E16;&#x4EE3;&#xFF1A;<code>&#x65B0;&#x751F;&#x4EE3;&#xFF08;Young generation&#xFF09;</code>&#x548C;<code>&#x8001;&#x5E74;&#x4EE3;&#xFF08;Old generation&#xFF09;</code>&#xFF0C;V8&#x5728;&#x8FD9;&#x4E2A;&#x4E24;&#x4E2A;&#x4E16;&#x4EE3;&#x7684;&#x524D;&#x63D0;&#x4E0B;&#xFF0C;&#x53C8;&#x589E;&#x52A0;&#x4E86;&#x72EC;&#x7279;&#x7684;&#x7A7A;&#x95F4;&#xFF0C;&#x7528;&#x6765;&#x5B58;&#x653E;&#x4E13;&#x95E8;&#x7684;&#x5BF9;&#x8C61;&#x3002;&#x4EE5;&#x4E0B;&#x662F;V8&#x5728;&#x5185;&#x5B58;&#x7BA1;&#x7406;&#x4E2D;&#x7684;&#x6240;&#x6709;&#x7A7A;&#x95F4;&#xFF1A;</p>
<pre><code>  RO_SPACE,    // Immortal, immovable and immutable objects,
  NEW_SPACE,   // Young generation semispaces for regular objects collected with
               // Scavenger.
  OLD_SPACE,   // Old generation regular object space.
  CODE_SPACE,  // Old generation code object space, marked executable.
  MAP_SPACE,   // Old generation map object space, non-movable.
  LO_SPACE,    // Old generation large object space.
  CODE_LO_SPACE,  // Old generation large code object space.
  NEW_LO_SPACE,   // Young generation large object space.
</code></pre>
<p>&#x8FD9;&#x4E9B;&#x7A7A;&#x95F4;&#x7EC4;&#x6210;&#x4E86;V8&#x7684;heap&#x7BA1;&#x7406;&#x5E76;&#x4E14;&#x5728;Isolate&#x521D;&#x59CB;&#x5316;&#x65F6;&#x5B8C;&#x6210;&#x5404;&#x81EA;&#x7A7A;&#x95F4;&#x7684;&#x521D;&#x59CB;&#x5316;&#x3002;<br>
&#x5728;&#x4E86;&#x89E3;&#x6BCF;&#x4E2A;&#x4E16;&#x4EE3;&#x7684;&#x5783;&#x573E;&#x56DE;&#x6536;&#x4E4B;&#x524D;&#xFF0C;&#x6211;&#x4EEC;&#x5148;&#x770B;&#x4E00;&#x4E0B;V8&#x7684;heap&#x7ED3;&#x6784;&#xFF1A;<br>
<img src="http://www.lichen.in/content/images/2020/03/4ac4842bc4dde9cbb4da78e60704dd56ce63ed4d.png" alt="4ac4842bc4dde9cbb4da78e60704dd56ce63ed4d" loading="lazy"></p>
<h2 id>&#x65B0;&#x751F;&#x4EE3;</h2>
<p>&#x65B0;&#x751F;&#x4EE3;&#x53C8;&#x5206;&#x4E86;&#x4E24;&#x4E2A;SemiSpace&#xFF08;from&#x548C;to&#xFF09;&#xFF0C;&#x9ED8;&#x8BA4;&#x7684;&#x521D;&#x59CB;&#x5316;&#x5BB9;&#x91CF;&#x662F;1MB&#x3001;&#x6700;&#x5927;&#x5BB9;&#x91CF;8MB&#xFF0C;&#x8FD9;2&#x4E2A;&#x7A7A;&#x95F4;&#x7C7B;&#x4F3C;&#x4E8E;Java&#x4E2D;&#x7684;Eden&#x548C;Survivor&#x533A;&#xFF0C;&#x8FD9;2&#x4E2A;&#x534A;&#x533A;&#x6BCF;&#x6B21;GC&#x540E;&#xFF0C;&#x603B;&#x6709;&#x4E00;&#x4E2A;&#x533A;&#x662F;&#x7A7A;&#x7684;&#xFF0C;&#x4E3A;&#x4EC0;&#x4E48;&#x5462;&#xFF1F;</p>
<blockquote>
<p>&#x6BCF;&#x6B21;&#x8FDB;&#x884C;minor GC&#x65F6;&#xFF0C;&#x5C06;from&#x533A;&#x4E2D;&#x4ECD;&#x7136;&#x5B58;&#x6D3B;&#x7684;&#x5BF9;&#x8C61;copy&#x5230;to&#x533A;&#xFF0C;&#x7136;&#x540E;&#x5C06;from&#x533A;&#x7684;&#x5185;&#x5B58;&#x5168;&#x90E8;&#x6E05;&#x9664;&#xFF0C;&#x7136;&#x540E;&#x8BBE;&#x7F6E;&#x4E24;&#x4E2A;&#x533A;&#x7684;page&#x7684;flag&#xFF0C;&#x5C06;FROM_PAGE&#x8BBE;&#x7F6E;&#x4E3A;TO_PAGE&#xFF0C;&#x8FD9;&#x6837;from&#x533A;&#x5C31;&#x6709;&#x4E4B;&#x6709;&#x4E4B;&#x524D;to&#x533A;&#x7684;&#x5B58;&#x6D3B;&#x5BF9;&#x8C61;&#xFF0C;&#x800C;to&#x533A;&#x7ECF;&#x8FC7;&#x4EA4;&#x6362;&#x6570;&#x636E;&#x540E;&#xFF0C;&#x6CA1;&#x6709;&#x5B58;&#x6D3B;&#x7684;&#x5BF9;&#x8C61;&#x4E86;&#xFF0C;&#x81EA;&#x7136;&#x5C31;&#x7A7A;&#x4E86;&#x3002;&#x867D;&#x7136;&#x65B0;&#x751F;&#x4EE3;&#x53EA;&#x6709;&#x4E00;&#x534A;&#x7684;&#x7A7A;&#x95F4;&#x5728;&#x4F7F;&#x7528;&#xFF0C;&#x4F46;&#x662F;&#x65B0;&#x751F;&#x4EE3;&#x7684;&#x5BF9;&#x8C61;&#xFF0C;&#x5927;&#x90E8;&#x5206;&#x751F;&#x547D;&#x5468;&#x671F;&#x90FD;&#x5F88;&#x77ED;&#xFF0C;&#x8FD9;&#x6837;&#x505A;&#x4E5F;&#x662F;&#x51FA;&#x4E8E;&#x6548;&#x7387;&#x7684;&#x8003;&#x8651;&#x3002;&#x7528;&#x7A7A;&#x95F4;&#x6362;&#x65F6;&#x95F4;&#xFF0C;&#x8FD9;&#x6837;&#x6548;&#x7387;&#x8FD8;&#x662F;&#x5F88;&#x9AD8;&#x7684;&#x3002;</p>
</blockquote>
<p><img src="http://www.lichen.in/content/images/2020/03/cheneys-semispace-copy.png" alt="cheneys-semispace-copy" loading="lazy"></p>
<p>&#x90A3;&#x4E48;V8&#x5185;&#x90E8;&#x662F;&#x5982;&#x4F55;&#x89E6;&#x53D1;&#x5185;&#x5B58;&#x56DE;&#x6536;&#x7684;&#x5462;&#xFF1F;&#x662F;&#x76D1;&#x542C;Heap&#x7684;&#x5185;&#x5B58;&#x5927;&#x5C0F;&#xFF1F;&#x8FD8;&#x662F;&#x5B9A;&#x671F;&#x4E3B;&#x52A8;&#x8FDB;&#x884C;GC&#xFF1F;&#x6211;&#x4EEC;&#x901A;&#x8FC7;&#x4EE3;&#x7801;&#x4E00;&#x63A2;&#x7A76;&#x7ADF;&#x3002;<br>
V8&#x4E2D;&#x7684;&#x6240;&#x6709;&#x5BF9;&#x8C61;&#x90FD;&#x662F;&#x901A;&#x8FC7;&#x5DE5;&#x7A0B;&#x65B9;&#x6CD5;&#x521B;&#x5EFA;&#x7684;&#x3002;&#x5B83;&#x6709;&#x4E00;&#x4E2A;&#x4E13;&#x95E8;&#x7684;&#x5DE5;&#x5382;&#x7C7B;(<a href="https://github.com/v8/v8/blob/master/src/heap/factory.h?ref=lichen.in">factory.h</a>)&#x7528;&#x6765;&#x521B;&#x5EFA;&#x6240;&#x6709;&#x7684;&#x5BF9;&#x8C61;&#x3002;</p>
<pre><code> Handle&lt;FixedArray&gt; NewFixedArray(
      int length, AllocationType allocation = AllocationType::kYoung);
Handle&lt;PropertyArray&gt; NewPropertyArray(
      int length, AllocationType allocation = AllocationType::kYoung);
MaybeHandle&lt;String&gt; NewStringFromOneByte(
      const Vector&lt;const uint8_t&gt;&amp; str,
      AllocationType allocation = AllocationType::kYoung);
MaybeHandle&lt;String&gt; NewStringFromUtf8(
      const Vector&lt;const char&gt;&amp; str,
      AllocationType allocation = AllocationType::kYoung);
Handle&lt;Struct&gt; NewStruct(InstanceType type,
                           AllocationType allocation = AllocationType::kYoung);
Handle&lt;ByteArray&gt; NewByteArray(
      int length, AllocationType allocation = AllocationType::kYoung);
Handle&lt;Object&gt; NewNumber(double value,
                           AllocationType allocation = AllocationType::kYoung);
Handle&lt;JSObject&gt; NewJSObject(
      Handle&lt;JSFunction&gt; constructor,
      AllocationType allocation = AllocationType::kYoung);
</code></pre>
<p>&#x8FD9;&#x91CC;&#x5217;&#x51FA;&#x4E86;&#x4E3B;&#x8981;&#x4F7F;&#x7528;&#x7684;API&#xFF0C;&#x4E0A;&#x8FF0;&#x8FD8;&#x6709;&#x5F88;&#x591A;API&#x6CA1;&#x6709;&#x5217;&#x51FA;&#xFF0C;&#x90FD;&#x662F;&#x4E0E;&#x521B;&#x5EFA;V8&#x5BF9;&#x8C61;&#x76F8;&#x5173;&#x7684;&#x3002;&#x6BCF;&#x4E2A;&#x5BF9;&#x8C61;&#x7684;&#x751F;&#x6210;&#x90FD;&#x4F1A;&#x8C03;&#x7528;<code>AllocateRawWithRetryOrFail</code>&#x8FD9;&#x4E2A;&#x65B9;&#x6CD5;</p>
<pre><code>HeapObject AllocateRawWithRetryOrFail(
      int size, AllocationType allocation,
      AllocationAlignment alignment = kWordAligned) {
      AllocationResult alloc;
  HeapObject result = AllocateRawWithLightRetry(size, allocation, alignment);
  if (!result.is_null()) return result;

  isolate()-&gt;counters()-&gt;gc_last_resort_from_handles()-&gt;Increment();
  CollectAllAvailableGarbage(GarbageCollectionReason::kLastResort);
  {
    AlwaysAllocateScope scope(isolate());
    alloc = AllocateRaw(size, allocation, alignment);
  }
  if (alloc.To(&amp;result)) {
    DCHECK(result != ReadOnlyRoots(this).exception());
    return result;
  }
  // TODO(1181417): Fix this.
  FatalProcessOutOfMemory(&quot;CALL_AND_RETRY_LAST&quot;);
  return HeapObject();
}
</code></pre>
<p><code>AllocateRawWithRetryOrFail</code>&#x4F1A;&#x5728;&#x8C03;&#x7528;<code>AllocateRawWithLightRetry</code>&#x548C;<code>AllocateRaw</code></p>
<pre><code>AllocateRawWithLightRetry-&gt;AllocateRaw-&gt;&#x751F;&#x6210;&#x5BF9;&#x8C61;
</code></pre>
<p><code>AllocateRaw</code>&#x4F1A;&#x9488;&#x5BF9; &#x4E0D;&#x540C;&#x7684;<code>AllocationType</code>&#x8C03;&#x7528;&#x5BF9;&#x5E94;space&#x751F;&#x6210;&#x5BF9;&#x8C61;&#x3002;&#x4EE3;&#x7801;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre><code>AllocationResult Heap::AllocateRaw(int size_in_bytes, AllocationType type,
                                   AllocationAlignment alignment) {
  DCHECK(AllowHandleAllocation::IsAllowed());
  DCHECK(AllowHeapAllocation::IsAllowed());
  DCHECK(gc_state_ == NOT_IN_GC);
#ifdef V8_ENABLE_ALLOCATION_TIMEOUT
  if (FLAG_random_gc_interval &gt; 0 || FLAG_gc_interval &gt;= 0) {
    if (!always_allocate() &amp;&amp; Heap::allocation_timeout_-- &lt;= 0) {
      return AllocationResult::Retry();
    }
  }
#endif
#ifdef DEBUG
  IncrementObjectCounters();
#endif

  bool large_object = size_in_bytes &gt; kMaxRegularHeapObjectSize;

  HeapObject object;
  AllocationResult allocation;

  if (AllocationType::kYoung == type) {
    if (large_object) {
      if (FLAG_young_generation_large_objects) {
        allocation = new_lo_space_-&gt;AllocateRaw(size_in_bytes);
      } else {
        // If young generation large objects are disalbed we have to tenure the
        // allocation and violate the given allocation type. This could be
        // dangerous. We may want to remove FLAG_young_generation_large_objects
        // and avoid patching.
        allocation = lo_space_-&gt;AllocateRaw(size_in_bytes);
      }
    } else {
      allocation = new_space_-&gt;AllocateRaw(size_in_bytes, alignment);
    }
  } else if (AllocationType::kOld == type) {
    if (large_object) {
      allocation = lo_space_-&gt;AllocateRaw(size_in_bytes);
    } else {
      allocation = old_space_-&gt;AllocateRaw(size_in_bytes, alignment);
    }
  } else if (AllocationType::kCode == type) {
    if (size_in_bytes &lt;= code_space()-&gt;AreaSize() &amp;&amp; !large_object) {
      allocation = code_space_-&gt;AllocateRawUnaligned(size_in_bytes);
    } else {
      allocation = code_lo_space_-&gt;AllocateRaw(size_in_bytes);
    }
  } else if (AllocationType::kMap == type) {
    allocation = map_space_-&gt;AllocateRawUnaligned(size_in_bytes);
  } else if (AllocationType::kReadOnly == type) {
#ifdef V8_USE_SNAPSHOT
    DCHECK(isolate_-&gt;serializer_enabled());
#endif
    DCHECK(!large_object);
    DCHECK(CanAllocateInReadOnlySpace());
    allocation = read_only_space_-&gt;AllocateRaw(size_in_bytes, alignment);
  } else {
    UNREACHABLE();
  }

  if (allocation.To(&amp;object)) {
    if (AllocationType::kCode == type) {
      // Unprotect the memory chunk of the object if it was not unprotected
      // already.
      UnprotectAndRegisterMemoryChunk(object);
      ZapCodeObject(object.address(), size_in_bytes);
      if (!large_object) {
        MemoryChunk::FromHeapObject(object)
            -&gt;GetCodeObjectRegistry()
            -&gt;RegisterNewlyAllocatedCodeObject(object.address());
      }
    }
    OnAllocationEvent(object, size_in_bytes);
  }

  return allocation;
}
</code></pre>
<h2 id>&#x8001;&#x5E74;&#x4EE3;</h2>
<p>&#x8001;&#x5E74;&#x4EE3;&#x7684;&#x5BF9;&#x8C61;&#x90FD;&#x662F;&#x7ECF;&#x8FC7;&#x4E86;&#x65B0;&#x751F;&#x4EE3;&#x4E00;&#x8F6E;GC&#xFF0C;&#x664B;&#x5347;&#x4E4B;&#x540E;&#x8F6C;&#x79FB;&#x8FC7;&#x6765;&#x7684;&#x3002;&#x53E6;&#x5916;&#x8001;&#x5E74;&#x4EE3;&#x53C8;&#x5305;&#x542B;<code>&#x65B0;&#x751F;&#x4EE3;&#x7684;&#x6307;&#x9488;&#x7A7A;&#x95F4;</code>&#x548C;<code>&#x65B0;&#x751F;&#x4EE3;&#x6570;&#x636E;&#x7A7A;&#x95F4;</code>&#xFF0C;&#x524D;&#x8005;&#x662F;&#x5305;&#x542B;&#x4E86;&#x6307;&#x5411;&#x65B0;&#x751F;&#x4EE3;&#x5BF9;&#x8C61;&#x6307;&#x9488;&#x7684;&#x5BF9;&#x8C61;&#xFF0C;&#x540E;&#x8005;&#x53EA;&#x4FDD;&#x5B58;&#x539F;&#x59CB;&#x6570;&#x636E;&#x5BF9;&#x8C61;&#xFF0C;&#x8FD9;&#x4E9B;&#x5BF9;&#x8C61;&#x6CA1;&#x6709;&#x6307;&#x5411;&#x5176;&#x4ED6;&#x5BF9;&#x8C61;&#x7684;&#x6307;&#x9488;&#x3002;</p>
<!--kg-card-end: markdown-->]]></content:encoded></item><item><title><![CDATA[[V8]使用VS Code调试V8代码]]></title><description><![CDATA[<p>&#x6700;&#x8FD1;&#x5728;&#x505A;&#x4E00;&#x4E9B;v8&#x7684;&#x9879;&#x76EE;&#x5F00;&#x53D1;,&#x5176;&#x4E2D;&#x9700;&#x8981;&#x8C03;&#x8BD5;&#x4E00;&#x4E9B;&#x4EE3;&#x7801;,&#x4F46;&#x662F;&#x603B;&#x662F;&#x6253;&#x5370;log&#x7684;&#x6548;&#x7387;&#x592A;&#x4F4E;,&#x6240;&#x4EE5;&#x7814;&#x7A76;&#x4E86;&#x4E00;&#x4E0B;&#x5982;&#x4F55;&#x5728;vscode&#x4E0A;&#x8C03;&#x8BD5;v8&#x4EE3;</p>]]></description><link>http://www.lichen.in/v8-shi-yong-vs-code/</link><guid isPermaLink="false">5bf4c81102b60c7f8b23f70f</guid><dc:creator><![CDATA[lichen]]></dc:creator><pubDate>Fri, 25 Aug 2023 20:38:21 GMT</pubDate><media:content url="http://www.lichen.in/content/images/2018/11/v8.svg" medium="image"/><content:encoded><![CDATA[<img src="http://www.lichen.in/content/images/2018/11/v8.svg" alt="[V8]&#x4F7F;&#x7528;VS Code&#x8C03;&#x8BD5;V8&#x4EE3;&#x7801;"><p>&#x6700;&#x8FD1;&#x5728;&#x505A;&#x4E00;&#x4E9B;v8&#x7684;&#x9879;&#x76EE;&#x5F00;&#x53D1;,&#x5176;&#x4E2D;&#x9700;&#x8981;&#x8C03;&#x8BD5;&#x4E00;&#x4E9B;&#x4EE3;&#x7801;,&#x4F46;&#x662F;&#x603B;&#x662F;&#x6253;&#x5370;log&#x7684;&#x6548;&#x7387;&#x592A;&#x4F4E;,&#x6240;&#x4EE5;&#x7814;&#x7A76;&#x4E86;&#x4E00;&#x4E0B;&#x5982;&#x4F55;&#x5728;vscode&#x4E0A;&#x8C03;&#x8BD5;v8&#x4EE3;&#x7801;.</p><!--kg-card-begin: markdown--><ol>
<li>&#x4F7F;&#x7528;vscode&#x6253;&#x5F00;v8&#x7684;&#x6E90;&#x4EE3;&#x7801;,&#x5728;v8&#x7684;&#x76EE;&#x5F55;&#x4E0B;&#x521B;&#x5EFA;.vscode&#x7684;&#x76EE;&#x5F55;,&#x8BE5;&#x76EE;&#x5F55;&#x662F;&#x5B58;&#x653E;vscode&#x7684;&#x914D;&#x7F6E;&#x4FE1;&#x606F;.</li>
<li>&#x65B0;&#x5EFA;launch.json</li>
</ol>
<pre><code>{
  &quot;version&quot;: &quot;0.2.0&quot;,
  &quot;configurations&quot;: [
  {
    &quot;name&quot;: &quot;v8 sample Debug&quot;,
    &quot;type&quot;: &quot;cppdbg&quot;,
    &quot;request&quot;: &quot;launch&quot;,
    &quot;targetArchitecture&quot;: &quot;x64&quot;,  //&#x8981;debug&#x80AF;&#x5B9A;&#x662F;&#x684C;&#x9762;&#x7248;&#x672C;&#x7684;
    &quot;program&quot;: &quot;${workspaceRoot}/out/Debug/v8_hello_world&quot;,
    &quot;args&quot;: [],  // Optional command line args
    &quot;preLaunchTask&quot;: &quot;build_v8_hello_world&quot;,  //&#x8FD9;&#x4E2A;&#x662F;&#x5728;debug&#x4E4B;&#x524D;&#x505A;&#x7684;&#x4EFB;&#x52A1;,&#x6BD4;&#x5982;&#x7F16;&#x8BD1;&#x7B49;,&#x53EF;&#x4EE5;&#x624B;&#x52A8;&#x81EA;&#x5DF1;&#x7F16;&#x8BD1;,&#x4E0D;&#x9700;&#x8981;&#x53EF;&#x4EE5;&#x6CE8;&#x91CA;&#x6389;
    &quot;stopAtEntry&quot;: false,
    &quot;cwd&quot;: &quot;${workspaceRoot}&quot;,
    &quot;environment&quot;: [{&quot;name&quot;:&quot;workspaceRoot&quot;,&quot;value&quot;:&quot;${HOME}/v8/src&quot;
    }],       //&#x8BBE;&#x7F6E;v8&#x7684;&#x73AF;&#x5883;&#x53D8;&#x91CF;,&#x5DE5;&#x4F5C;&#x76EE;&#x5F55;
    &quot;externalConsole&quot;: false  //&#x4F7F;&#x7528;&#x5185;&#x7F6E;&#x7684;console
  }]
}
</code></pre>
<p>3.&#x65B0;&#x5EFA;tasks.json (&#x53EF;&#x9009;)</p>
<pre><code>{
  &quot;showOutput&quot;: &quot;always&quot;,
  &quot;echoCommand&quot;: true,
  &quot;tasks&quot;: [
  {
    &quot;taskName&quot;: &quot;build_v8_hello_world&quot;,
    &quot;command&quot;: &quot;ninja -C out/Debug v8_hello_world&quot;, //&#x7F16;&#x8BD1;sample&#x4EE3;&#x7801;
    &quot;isShellCommand&quot;: true,
    &quot;isTestCommand&quot;: true,
    &quot;problemMatcher&quot;: [
    {
      &quot;owner&quot;: &quot;cpp&quot;,
      &quot;fileLocation&quot;: [&quot;relative&quot;, &quot;${workspaceRoot}&quot;],
      &quot;pattern&quot;: {
        &quot;regexp&quot;: &quot;^../../(.*):(\\d+):(\\d+):\\s+(warning|\\w*\\s?error):\\s+(.*)$&quot;,
        &quot;file&quot;: 1, &quot;line&quot;: 2, &quot;column&quot;: 3, &quot;severity&quot;: 4, &quot;message&quot;: 5
      }
    },
    {
      &quot;owner&quot;: &quot;cpp&quot;,
      &quot;fileLocation&quot;: [&quot;relative&quot;, &quot;${workspaceRoot}&quot;],
      &quot;pattern&quot;: {
        &quot;regexp&quot;: &quot;^../../(.*?):(.*):\\s+(warning|\\w*\\s?error):\\s+(.*)$&quot;,
        &quot;file&quot;: 1, &quot;severity&quot;: 3, &quot;message&quot;: 4
      }
    }]
  }]
}
</code></pre>
<ol start="4">
<li>
<p>&#x8FD9;&#x65F6;&#x53EF;&#x4EE5;&#x770B;&#x5230;&#x5728;vscode&#x7684;&#x8C03;&#x8BD5;&#x754C;&#x9762;,&#x5DF2;&#x7ECF;&#x53EF;&#x4EE5;&#x770B;&#x5230;&#x6211;&#x4EEC;&#x5728;<strong>launch.json</strong>&#x4E2D;&#x914D;&#x7F6E;&#x7684;&#x5185;&#x5BB9;&#x4E86;.<br>
<img src="http://www.lichen.in/content/images/2018/11/---.png" alt="[V8]&#x4F7F;&#x7528;VS Code&#x8C03;&#x8BD5;V8&#x4EE3;&#x7801;" loading="lazy"></p>
</li>
<li>
<p>&#x914D;&#x7F6E;&#x5B8C;&#x6210;&#x4E4B;&#x540E;,&#x73B0;&#x5728;&#x8981;&#x914D;&#x7F6E;gn&#x7684;&#x4FE1;&#x606F;&#x4E86;.</p>
</li>
</ol>
<pre><code>gn --args=&apos;is_debug= true dcheck_always_on = true is_component_build = true enable_nacl = false v8_optimized_debug = false &apos; gen src/out/Debug
</code></pre>
<p>&#x8FD9;&#x91CC;&#x6709;2&#x4E2A;&#x70B9;&#x9700;&#x8981;&#x6CE8;&#x610F;,&#x4E00;&#x662F;<strong>is_debug= true</strong>,&#x8FD9;&#x4E2A;&#x6807;&#x8BB0;&#x662F;&#x5426;&#x5F00;&#x542F;&#x8C03;&#x8BD5;&#x6A21;&#x5F0F;,&#x4E8C;&#x662F;<strong>v8_optimized_debug = false</strong>,&#x8FD9;&#x4E2A;&#x6807;&#x8BB0;&#x4EE3;&#x8868;&#x662F;&#x5426;&#x5BF9;v8&#x7684;&#x4EE3;&#x7801;&#x5728;&#x7F16;&#x8BD1;&#x65F6;&#x4F18;&#x5316;,&#x6211;&#x4EEC;&#x77E5;&#x9053;gcc&#x7F16;&#x8BD1;&#x65F6;,&#x6709;-O0,-O1,-O2,-O3&#x8FD9;&#x51E0;&#x6863;&#x6765;&#x4F18;&#x5316;&#x4EE3;&#x7801;,&#x51CF;&#x5C11;&#x4EA7;&#x751F;&#x7684;&#x4F53;&#x79EF;.<br>
1.-O0:<br>
&#x4E0D;&#x4F18;&#x5316;.<br>
2.-O1&#xFF1A;<br>
&#x8FD9;&#x4E24;&#x4E2A;&#x547D;&#x4EE4;&#x7684;&#x6548;&#x679C;&#x662F;&#x4E00;&#x6837;&#x7684;&#xFF0C;&#x76EE;&#x7684;&#x90FD;&#x662F;&#x5728;&#x4E0D;&#x5F71;&#x54CD;&#x7F16;&#x8BD1;&#x901F;&#x5EA6;&#x7684;&#x524D;&#x63D0;&#x4E0B;&#xFF0C;&#x5C3D;&#x91CF;&#x91C7;&#x7528;&#x4E00;&#x4E9B;&#x4F18;&#x5316;&#x7B97;&#x6CD5;&#x964D;&#x4F4E;&#x4EE3;&#x7801;&#x5927;&#x5C0F;&#x548C;&#x53EF;&#x6267;&#x884C;&#x4EE3;&#x7801;&#x7684;&#x8FD0;&#x884C;&#x901F;&#x5EA6;&#x3002;&#x5E76;&#x5F00;&#x542F;&#x5982;&#x4E0B;&#x7684;&#x4F18;&#x5316;&#x9009;&#x9879;&#xFF1A;</p>
<pre><code>-fauto-inc-dec 
-fbranch-count-reg 
-fcombine-stack-adjustments 
-fcompare-elim 
-fcprop-registers 
-fdce 
-fdefer-pop 
-fdelayed-branch 
-fdse 
-fforward-propagate 
-fguess-branch-probability 
-fif-conversion2 
-fif-conversion 
-finline-functions-called-once 
-fipa-pure-const 
-fipa-profile 
-fipa-reference 
-fmerge-constants 
-fmove-loop-invariants 
-freorder-blocks 
-fshrink-wrap 
-fshrink-wrap-separate 
-fsplit-wide-types 
-fssa-backprop 
-fssa-phiopt 
-fstore-merging 
-ftree-bit-ccp 
-ftree-ccp 
-ftree-ch 
-ftree-coalesce-vars 
-ftree-copy-prop 
-ftree-dce 
-ftree-dominator-opts 
-ftree-dse 
-ftree-forwprop 
-ftree-fre 
-ftree-phiprop 
-ftree-sink 
-ftree-slsr 
-ftree-sra 
-ftree-pta 
-ftree-ter 
-funit-at-a-time
</code></pre>
<ol start="3">
<li>-O2<br>
&#x8BE5;&#x4F18;&#x5316;&#x9009;&#x9879;&#x4F1A;&#x727A;&#x7272;&#x90E8;&#x5206;&#x7F16;&#x8BD1;&#x901F;&#x5EA6;&#xFF0C;&#x9664;&#x4E86;&#x6267;&#x884C;-O1&#x6240;&#x6267;&#x884C;&#x7684;&#x6240;&#x6709;&#x4F18;&#x5316;&#x4E4B;&#x5916;&#xFF0C;&#x8FD8;&#x4F1A;&#x91C7;&#x7528;&#x51E0;&#x4E4E;&#x6240;&#x6709;&#x7684;&#x76EE;&#x6807;&#x914D;&#x7F6E;&#x652F;&#x6301;&#x7684;&#x4F18;&#x5316;&#x7B97;&#x6CD5;&#xFF0C;&#x7528;&#x4EE5;&#x63D0;&#x9AD8;&#x76EE;&#x6807;&#x4EE3;&#x7801;&#x7684;&#x8FD0;&#x884C;&#x901F;&#x5EA6;&#x3002;</li>
</ol>
<pre><code>-fthread-jumps 
-falign-functions  -falign-jumps 
-falign-loops  -falign-labels 
-fcaller-saves 
-fcrossjumping 
-fcse-follow-jumps  -fcse-skip-blocks 
-fdelete-null-pointer-checks 
-fdevirtualize -fdevirtualize-speculatively 
-fexpensive-optimizations 
-fgcse  -fgcse-lm  
-fhoist-adjacent-loads 
-finline-small-functions 
-findirect-inlining 
-fipa-cp 
-fipa-cp-alignment 
-fipa-bit-cp 
-fipa-sra 
-fipa-icf 
-fisolate-erroneous-paths-dereference 
-flra-remat 
-foptimize-sibling-calls 
-foptimize-strlen 
-fpartial-inlining 
-fpeephole2 
-freorder-blocks-algorithm=stc 
-freorder-blocks-and-partition -freorder-functions 
-frerun-cse-after-loop  
-fsched-interblock  -fsched-spec 
-fschedule-insns  -fschedule-insns2 
-fstrict-aliasing -fstrict-overflow 
-ftree-builtin-call-dce 
-ftree-switch-conversion -ftree-tail-merge 
-fcode-hoisting 
-ftree-pre 
-ftree-vrp 
-fipa-ra
</code></pre>
<ol start="4">
<li>-O3<br>
&#x8BE5;&#x9009;&#x9879;&#x9664;&#x4E86;&#x6267;&#x884C;-O2&#x6240;&#x6709;&#x7684;&#x4F18;&#x5316;&#x9009;&#x9879;&#x4E4B;&#x5916;&#xFF0C;&#x4E00;&#x822C;&#x90FD;&#x662F;&#x91C7;&#x53D6;&#x5F88;&#x591A;&#x5411;&#x91CF;&#x5316;&#x7B97;&#x6CD5;&#xFF0C;&#x63D0;&#x9AD8;&#x4EE3;&#x7801;&#x7684;&#x5E76;&#x884C;&#x6267;&#x884C;&#x7A0B;&#x5EA6;&#xFF0C;&#x5229;&#x7528;&#x73B0;&#x4EE3;CPU&#x4E2D;&#x7684;&#x6D41;&#x6C34;&#x7EBF;&#xFF0C;Cache&#x7B49;&#x3002;</li>
</ol>
<pre><code>-finline-functions      // &#x91C7;&#x7528;&#x4E00;&#x4E9B;&#x542F;&#x53D1;&#x5F0F;&#x7B97;&#x6CD5;&#x5BF9;&#x51FD;&#x6570;&#x8FDB;&#x884C;&#x5185;&#x8054;
-funswitch-loops        // &#x6267;&#x884C;&#x5FAA;&#x73AF;unswitch&#x53D8;&#x6362;
-fpredictive-commoning  // 
-fgcse-after-reload     //&#x6267;&#x884C;&#x5168;&#x5C40;&#x7684;&#x5171;&#x540C;&#x5B50;&#x8868;&#x8FBE;&#x5F0F;&#x6D88;&#x9664;
-ftree-loop-vectorize&#x3000;  // 
-ftree-loop-distribute-patterns
-fsplit-paths 
-ftree-slp-vectorize
-fvect-cost-model
-ftree-partial-pre
-fpeel-loops 
-fipa-cp-clone options
</code></pre>
<p>&#x8FD9;&#x4E2A;&#x9009;&#x9879;&#x4F1A;&#x63D0;&#x9AD8;&#x6267;&#x884C;&#x4EE3;&#x7801;&#x7684;&#x5927;&#x5C0F;&#xFF0C;&#x5F53;&#x7136;&#x4F1A;&#x964D;&#x4F4E;&#x76EE;&#x6807;&#x4EE3;&#x7801;&#x7684;&#x6267;&#x884C;&#x65F6;&#x95F4;&#x3002;</p>
<ol start="6">
<li>&#x73B0;&#x5728;&#x914D;&#x7F6E;&#x90FD;&#x57FA;&#x672C;&#x5B8C;&#x6210;&#x4E86;,&#x73B0;&#x5728;&#x6309;&#x4E0B;F5,&#x8FDB;&#x884C;&#x8C03;&#x8BD5;,&#x6211;&#x4EEC;&#x5C31;&#x53EF;&#x4EE5;&#x770B;&#x5230;&#x5982;&#x4E0B;&#x7684;&#x5185;&#x5BB9;&#x4E86;.<br>
<img src="http://www.lichen.in/content/images/2018/11/SEA10O-C.PNG" alt="[V8]&#x4F7F;&#x7528;VS Code&#x8C03;&#x8BD5;V8&#x4EE3;&#x7801;" loading="lazy"></li>
</ol>
<p>&#x81F3;&#x6B64;,&#x8C03;&#x8BD5;&#x5DE5;&#x4F5C;&#x6B63;&#x5F0F;&#x5F00;&#x59CB;</p>
<!--kg-card-end: markdown-->]]></content:encoded></item><item><title><![CDATA[Android InputFilter的详细解析]]></title><description><![CDATA[<!--kg-card-begin: markdown--><p>InputFilter&#x8FD9;&#x4E2A;interface&#x76F8;&#x4FE1;&#x5927;&#x5BB6;&#x4E5F;&#x4E0D;&#x4F1A;&#x964C;&#x751F;,&#x4EFB;&#x4F55;&#x5BF9;EditText&#x7684;&#x8F93;&#x5165;&#x7B2C;&#x4E00;&#x6B65;&#x5C31;&#x4F1A;&#x7ECF;&#x8FC7;&#x5B83;,&#x800C;&#x5B83;&#x7684;&#x540D;&#x5B57;&#x4E5F;&#x5341;&#x5206;&#x7684;&#x76F4;&#x767D;&#x2014;&#x2014;&#x8F93;&#x5165;&#x8FC7;&#x6EE4;&#x5668;.InputFilter&#x53EA;&#x6709;&#x4E00;</p>]]></description><link>http://www.lichen.in/android-inputfilterde-xiang-xi-jie-xi/</link><guid isPermaLink="false">5b7d0232cc63df2ef9d26d4f</guid><dc:creator><![CDATA[lichen]]></dc:creator><pubDate>Fri, 25 Aug 2023 20:38:08 GMT</pubDate><content:encoded><![CDATA[<!--kg-card-begin: markdown--><p>InputFilter&#x8FD9;&#x4E2A;interface&#x76F8;&#x4FE1;&#x5927;&#x5BB6;&#x4E5F;&#x4E0D;&#x4F1A;&#x964C;&#x751F;,&#x4EFB;&#x4F55;&#x5BF9;EditText&#x7684;&#x8F93;&#x5165;&#x7B2C;&#x4E00;&#x6B65;&#x5C31;&#x4F1A;&#x7ECF;&#x8FC7;&#x5B83;,&#x800C;&#x5B83;&#x7684;&#x540D;&#x5B57;&#x4E5F;&#x5341;&#x5206;&#x7684;&#x76F4;&#x767D;&#x2014;&#x2014;&#x8F93;&#x5165;&#x8FC7;&#x6EE4;&#x5668;.InputFilter&#x53EA;&#x6709;&#x4E00;&#x4E2A;&#x65B9;&#x6CD5;,&#x5C31;&#x662F;<code>filter</code>&#x65B9;&#x6CD5;,&#x800C;&#x8FD9;&#x4E2A;&#x65B9;&#x6CD5;&#x5374;&#x5BF9;&#x4F60;&#x7684;&#x8F93;&#x5165;&#x8FC7;&#x6EE4;&#x6709;&#x7740;&#x81F3;&#x5173;&#x91CD;&#x8981;&#x7684;&#x7ED3;&#x679C;,&#x6211;&#x4EEC;&#x73B0;&#x5728;&#x770B;&#x770B;google&#x7684;&#x5B98;&#x65B9;&#x6587;&#x6863;&#x662F;&#x600E;&#x4E48;&#x63CF;&#x8FF0;&#x8FD9;&#x4E2A;<code>filter</code>&#x65B9;&#x6CD5;&#x7684;.</p>
<blockquote>
<p>This method is called when the buffer is going to replace the range dstart &#x2026; dend of dest with the new text from the range start &#x2026; end of source. Return the CharSequence that you would like to have placed there instead, including an empty string if appropriate, or null to accept the original replacement. Be careful to not to reject 0-length replacements, as this is what happens when you delete text. Also beware that you should not attempt to make any changes to dest from this method; you may only examine it for context. Note: If <strong>source</strong> is an instance of <a href="https://developer.android.com/reference/android/text/Spanned.html?ref=lichen.in">Spanned</a> or <a href="https://developer.android.com/reference/android/text/Spannable.html?ref=lichen.in">Spannable</a>, the span objects in the <strong>source</strong> should be copied into the filtered result (i.e. the non-null return value). [copySpansFrom(Spanned, int, int, Class, Spannable, int)](<a href="https://developer.android.com/reference/android/text/TextUtils.html?ref=lichen.in#copySpansFrom">https://developer.android.com/reference/android/text/TextUtils.html#copySpansFrom</a>(android.text.Spanned, int, int, java.lang.Class, android.text.Spannable, int)) can be used for convenience.</p>
</blockquote>
<p>&#x7B80;&#x5355;&#x7FFB;&#x8BD1;:&#x5F53;&#x6765;&#x81EA;source&#x7684;&#x65B0;&#x5185;&#x5BB9;(start--end)&#x5C06;&#x8981;&#x66FF;&#x6362;&#x4E4B;&#x524D;&#x7684;&#x5185;&#x5BB9;(dstart--dend)&#x65F6;&#x8BE5;&#x65B9;&#x6CD5;&#x88AB;&#x8C03;&#x7528;,&#x8FD4;&#x56DE;&#x4E00;&#x4E32;&#x5B57;&#x7B26;&#x4E32;,&#x4F7F;&#x7528;source&#x7684;&#x5185;&#x5BB9;&#x66FF;&#x4EE3;,&#x5305;&#x62EC;&#x7A7A;&#x5B57;&#x7B26;&#x4E32;&#x548C;null&#x90FD;&#x53EF;&#x4EE5;&#x66FF;&#x6362;&#x539F;&#x59CB;&#x7684;&#x4F4D;&#x7F6E;.&#x9700;&#x8981;&#x6CE8;&#x610F;&#x7684;&#x662F;&#x5F53;&#x6587;&#x672C;&#x88AB;&#x5220;&#x9664;&#x65F6;&#xFF0C;&#x6211;&#x4EEC;&#x53EF;&#x80FD;&#x4F1A;&#x4F7F;&#x7528;0-length&#x7684;&#x66FF;&#x6362;&#x3002;&#x53E6;&#x5916;&#x8FD8;&#x8981;&#x6CE8;&#x610F;&#x7684;&#x662F;&#xFF0C;&#x4F60;&#x4E0D;&#x5E94;&#x8BE5;&#x5728;&#x8FD9;&#x4E2A;&#x65B9;&#x6CD5;&#x91CC;&#x5BF9;&#x539F;&#x59CB;&#x5185;&#x5BB9;&#x505A;&#x4EFB;&#x4F55;&#x6539;&#x52A8;&#xFF0C;&#x4F60;&#x53EA;&#x662F;&#x9700;&#x8981;&#x68C0;&#x67E5;&#x5B83;&#x7684;&#x4E0A;&#x4E0B;&#x6587;&#x3002;&#x5F53;&#x7F13;&#x51B2;&#x533A;&#x8981;&#x7528;&#x6E90;&#x7684;&#x8303;&#x56F4;start ... end&#x4E2D;&#x7684;&#x65B0;&#x6587;&#x672C;&#x66FF;&#x6362;dest&#x7684;&#x8303;&#x56F4;dstart ... dend&#x65F6;&#xFF0C;&#x5C06;&#x8C03;&#x7528;&#x6B64;&#x65B9;&#x6CD5;&#x3002; &#x8FD4;&#x56DE;&#x60A8;&#x5E0C;&#x671B;&#x653E;&#x7F6E;&#x7684;CharSequence&#xFF0C;&#x5305;&#x62EC;&#x7A7A;&#x5B57;&#x7B26;&#x4E32;&#xFF08;&#x5982;&#x679C;&#x9002;&#x7528;&#xFF09;&#xFF0C;&#x6216;null&#x4EE5;&#x63A5;&#x53D7;&#x539F;&#x59CB;&#x66FF;&#x6362;&#x3002; &#x5C0F;&#x5FC3;&#x4E0D;&#x8981;&#x62D2;&#x7EDD;0&#x957F;&#x5EA6;&#x66FF;&#x6362;&#xFF0C;&#x56E0;&#x4E3A;&#x5220;&#x9664;&#x6587;&#x672C;&#x65F6;&#x4F1A;&#x53D1;&#x751F;&#x8FD9;&#x79CD;&#x60C5;&#x51B5;&#x3002; &#x8FD8;&#x8981;&#x6CE8;&#x610F;&#xFF0C;&#x60A8;&#x4E0D;&#x5E94;&#x8BE5;&#x5C1D;&#x8BD5;&#x5BF9;&#x6B64;&#x65B9;&#x6CD5;&#x7684;dest&#x8FDB;&#x884C;&#x4EFB;&#x4F55;&#x66F4;&#x6539;; &#x4F60;&#x53EF;&#x80FD;&#x53EA;&#x4F1A;&#x68C0;&#x67E5;&#x5B83;&#x7684;&#x4E0A;&#x4E0B;&#x6587;&#x3002; &#x6CE8;&#x610F;&#xFF1A;&#x5982;&#x679C;source&#x662F;Spanned&#x6216;Spannable&#x7684;&#x5B9E;&#x4F8B;&#xFF0C;&#x5219;&#x5E94;&#x5C06;&#x6E90;&#x4E2D;&#x7684;span&#x5BF9;&#x8C61;&#x590D;&#x5236;&#x5230;&#x7B5B;&#x9009;&#x7ED3;&#x679C;&#x4E2D;&#xFF08;&#x5373;&#x975E;null&#x8FD4;&#x56DE;&#x503C;&#xFF09;&#x3002; &#x5728;copySpansFrom&#xFF08;Spanned&#xFF0C;int&#xFF0C;int&#xFF0C;Class&#xFF0C;Spannable&#xFF0C;int&#xFF09;&#x4E2D;&#x8FDB;&#x884C;&#x5904;&#x7406;&#x3002;</p>
<p>&#x5728;&#x4F7F;&#x7528;InputFilter&#x65F6;,&#x4E00;&#x822C;&#x60C5;&#x51B5;&#x4E0B;&#x90FD;&#x65F6;&#x5728;&#x7528;&#x8FC7;&#x952E;&#x76D8;&#x8F93;&#x5165;&#x65F6;,&#x9700;&#x8981;&#x8FC7;&#x6EE4;&#x7684;&#x5185;&#x5BB9;,&#x8FD9;&#x662F;&#x8F93;&#x5165;source&#x4E00;&#x822C;&#x8F93;&#x5165;&#x7684;&#x7C7B;&#x578B;&#x4E3A;Spanned&#x7684;,&#x800C;&#x4E14;&#x91CC;&#x9762;&#x4F1A;&#x6709;UnderlineSpan.class&#x7684;&#x7C7B;&#x578B;&#x7684;Span&#x5728;source&#x91CC;,&#x6240;&#x4EE5;&#x8FD9;&#x662F;&#x663E;&#x793A;&#x5728;EditText&#x4E0A;&#x7684;&#x5185;&#x5BB9;&#x662F;&#x5E26;&#x4E0B;&#x5212;&#x7EBF;&#x7684;,&#x4E5F;&#x8BA9;&#x7528;&#x6237;&#x660E;&#x767D;&#x73B0;&#x5728;&#x662F;&#x5F85;&#x8F93;&#x5165;&#x72B6;&#x6001;.</p>
<img src="http://www.lichen.in/content/images/2018/09/Screenshot_1536563300.png" width="540" hegiht="720" align="center">
&#x5F53;&#x5728;&#x8F93;&#x5165;&#x6846;&#x4E2D;&#x8F93;&#x5165;apple&#x65F6;,&#x6211;&#x4EEC;&#x770B;&#x5230;log&#x5982;&#x4E0B;&#x7684;&#x8F93;&#x51FA;,&#x53D1;&#x73B0;source&#x662F;&#x548C;&#x4E0A;&#x9762;&#x8BF4;&#x7684;&#x4E00;&#x81F4;&#x7684;,&#x5B83;&#x5E76;&#x4E0D;&#x662F;&#x666E;&#x901A;&#x7684;CharSequence,&#x800C;&#x662F;spanned.
```
I/System.out: source is spanned:true src:a|dest:|dest is spanned:true
I/System.out: source is spanned:true src:ap|dest:a|dest is spanned:true
I/System.out: source is spanned:true src:app|dest:ap|dest is spanned:true
I/System.out: source is spanned:true src:appl|dest:app|dest is spanned:true
I/System.out: source is spanned:true src:apple|dest:appl|dest is spanned:true
```
<p>&#x5F53;&#x6211;&#x7EE7;&#x7EED;&#x5728;&#x8F93;&#x5165;&#x6CD5;&#x4E2D;&#x9009;&#x53D6;Apple&#x8FD9;&#x4E2A;&#x5355;&#x8BCD;&#x65F6;,log&#x6709;&#x5982;&#x4E0B;&#x8F93;&#x51FA;:</p>
<pre><code>I/System.out: source is spanned:false src:|dest:apple|dest is spanned:true
I/System.out: source is spanned:false src:Apple|dest:|dest is spanned:true
I/System.out: source is spanned:true src:|dest:Apple|dest is spanned:true
</code></pre>
<p>&#x8FD9;&#x4E09;&#x4E2A;log&#x8F93;&#x51FA;&#x5E94;&#x8BE5;&#x90FD;&#x65F6;&#x7531;&#x8F93;&#x5165;&#x6CD5;&#x89E6;&#x53D1;&#x7684;,&#x6240;&#x4EE5;&#x5982;&#x679C;&#x4F60;&#x9700;&#x8981;&#x8FC7;&#x6EE4;&#x7528;&#x6237;&#x7684;&#x8F93;&#x5165;&#x60C5;&#x51B5;,&#x90A3;&#x4E48;&#x4E00;&#x5B9A;&#x8981;&#x8003;&#x8651;&#x5230;&#x7528;&#x6237;&#x8F93;&#x5165;&#x6216;&#x8005;&#x7C98;&#x8D34;&#x7684;&#x5185;&#x5BB9;&#x662F;&#x5426;&#x662F;&#x5E26;&#x6709;spann&#x6837;&#x5F0F;&#x7684;.</p>
<p>&#x5982;&#x679C;&#x53EA;&#x662F;&#x9700;&#x8981;&#x53BB;&#x9664;&#x7C98;&#x8D34;&#x677F;&#x4E2D;spann&#x7684;&#x6837;&#x5F0F;.&#x53EA;&#x9700;:</p>
<pre><code>onTextContextMenuItem(ID_PASTE_AS_PLAIN_TEXT)
</code></pre>
<p>&#x5373;&#x53EF;</p>
<!--kg-card-end: markdown-->]]></content:encoded></item><item><title><![CDATA[[LeetCode]198. House Robber解题报告]]></title><description><![CDATA[<!--kg-card-begin: markdown--><script type="text/javascript" src="https://cdn.bootcss.com/mathjax/2.7.4/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>
<blockquote>
<p>You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjacent houses have security system connected and <strong>it will automatically contact the police if two adjacent houses</strong></p></blockquote>]]></description><link>http://www.lichen.in/leetcode-198-house-robberjie-ti-bao-gao/</link><guid isPermaLink="false">5b7d0232cc63df2ef9d26d50</guid><dc:creator><![CDATA[lichen]]></dc:creator><pubDate>Fri, 25 Aug 2023 20:37:54 GMT</pubDate><media:content url="http://www.lichen.in/content/images/2018/08/v2-edf39cfbc89d82b3e941cc84b2b65f0e_1200x500.jpg" medium="image"/><content:encoded><![CDATA[<!--kg-card-begin: markdown--><script type="text/javascript" src="https://cdn.bootcss.com/mathjax/2.7.4/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>
<blockquote>
<img src="http://www.lichen.in/content/images/2018/08/v2-edf39cfbc89d82b3e941cc84b2b65f0e_1200x500.jpg" alt="[LeetCode]198. House Robber&#x89E3;&#x9898;&#x62A5;&#x544A;"><p>You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjacent houses have security system connected and <strong>it will automatically contact the police if two adjacent houses were broken into on the same night.</strong></p>
</blockquote>
<blockquote>
<p>Given a list of non-negative integers representing the amount of money of each house, determine the maximum amount of money you can rob tonight <strong>without alerting the police.</strong></p>
</blockquote>
<p>&#x5927;&#x81F4;&#x610F;&#x601D;&#x5C31;&#x662F;&#x4F60;&#x662F;&#x804C;&#x4E1A;&#x7A83;&#x8D3C;,&#x8BA1;&#x5212;&#x6CBF;&#x7740;&#x4E00;&#x6761;&#x8857;&#x9053;&#x62A2;&#x52AB;,&#x6BCF;&#x4E2A;&#x623F;&#x5B50;&#x90FD;&#x85CF;&#x6709;&#x56FA;&#x5B9A;&#x4EF7;&#x503C;&#x7684;&#x94B1;,&#x552F;&#x4E00;&#x7684;&#x7EA6;&#x675F;&#x6761;&#x4EF6;&#x5C31;&#x662F;&#x4F60;&#x4E0D;&#x80FD;&#x6BCF;&#x4E00;&#x623F;&#x5B50;&#x90FD;&#x53BB;&#x62A2;&#x52AB;,&#x56E0;&#x4E3A;&#x76F8;&#x90BB;&#x7684;&#x623F;&#x5B50;&#x6709;&#x76F8;&#x8FDE;&#x63A5;&#x7684;&#x5B89;&#x5168;&#x7CFB;&#x7EDF;,&#x5982;&#x679C;&#x76F8;&#x90BB;&#x7684;&#x623F;&#x5B50;&#x90FD;&#x88AB;&#x62A2;&#x4E86;,&#x5B89;&#x5168;&#x7CFB;&#x7EDF;&#x5C31;&#x4F1A;&#x81EA;&#x52A8;&#x8054;&#x7CFB;&#x8B66;&#x5BDF;.</p>
<p>&#x73B0;&#x5728;&#x7ED9;&#x5B9A;&#x4E00;&#x7EC4;&#x975E;&#x8D1F;&#x6570;&#x7EC4;&#x4EE3;&#x8868;&#x6BCF;&#x4E2A;&#x623F;&#x5B50;&#x6240;&#x85CF;&#x6709;&#x94B1;&#x7684;&#x6570;&#x91CF;,&#x5982;&#x4F55;&#x5728;&#x4E0D;&#x88AB;&#x62A5;&#x8B66;&#x7684;&#x60C5;&#x51B5;&#x4E0B;&#x62A2;&#x5230;&#x6700;&#x5927;&#x503C;&#x7684;&#x94B1;.</p>
<p>&#x770B;&#x5230;&#x9898;&#x76EE;&#x7ED3;&#x5C3E;&#x8BF4;&#x8981;&#x6700;&#x5927;&#x503C;,&#x7B2C;&#x4E00;&#x53CD;&#x5E94;&#x5C31;&#x662F;&#x53EF;&#x4EE5;&#x7528;&#x66B4;&#x529B;&#x641C;&#x7D22;&#x89E3;&#x51B3;&#x8FD9;&#x4E2A;&#x95EE;&#x9898;.</p>
<pre><code>class Solution {
    
    int maxMoney(int index, int[] nums) {
			if (index &lt; 0) {
				return 0;
			}
			return Math.max(nums[index] + maxMoney(index - 2, nums), maxMoney(index - 1, nums));
		}

		public int rob(int[] nums) {
			return maxMoney(nums.length - 1, nums);
		}
}
</code></pre>
<p>&#x4E3B;&#x8981;&#x903B;&#x8F91;&#x5C31;&#x5728;<code>maxMoney(int index, int[] nums)</code>&#x4E2D;,<code>index</code>&#x4EE3;&#x8868;&#x4F60;&#x62A2;&#x5230;&#x7B2C;&#x51E0;&#x5BB6;,&#x540E;&#x7EED;<code>return</code>&#x66B4;&#x529B;&#x641C;&#x7D22;&#x7ED3;&#x679C;&#x7684;&#x8FC7;&#x7A0B;,&#x6839;&#x636E;&#x6761;&#x4EF6;&#x9650;&#x5236;,&#x5982;&#x679C;&#x4F60;&#x62A2;&#x4E86;&#x7B2C;<code>index</code>&#x5BB6;,&#x90A3;&#x4E48;&#x4F60;&#x6700;&#x8FD1;&#x80FD;&#x62A2;&#x7684;&#x4E00;&#x5BB6;&#x5C31;&#x4E3A;<code>index-2</code>,&#x90A3;&#x4E48;&#x5F53;&#x4F60;&#x62A2;&#x5230;&#x7B2C;<code>index</code>&#x5BB6;&#x65F6;,&#x4F60;&#x7684;&#x603B;&#x94B1;&#x6570;&#x5C31;&#x662F;<code>nums[index](&#x7B2C;index&#x5BB6;&#x7684;&#x94B1;&#x6570;&#x91CF;)+maxMoney(index - 2, nums)(&#x6700;&#x8FD1;1&#x6B21;&#x62A2;&#x7684;&#x5BB6;&#x7684;&#x94B1;&#x7684;&#x603B;&#x6570;)</code>&#x548C;&#x5982;&#x679C;&#x4F60;&#x4E0D;&#x62A2;&#x7B2C;<code>index</code>&#x5BB6;&#x65F6;,&#x90A3;&#x4E48;&#x4F60;&#x7684;&#x603B;&#x94B1;&#x6570;&#x5C31;&#x662F;<code>maxMoney(index - 1, nums)</code>,&#x5728;&#x8FD9;2&#x4E2A;&#x603B;&#x6570;&#x4E2D;&#x95F4;&#x53D6;1&#x4E2A;&#x66F4;&#x5927;&#x7684;&#x503C;.</p>
<p>&#x4ED4;&#x7EC6;&#x601D;&#x8003;&#x4E4B;&#x540E;,&#x8FD9;&#x9053;&#x9898;&#x7528;Dynamic Programming&#x4E5F;&#x80FD;&#x505A;,&#x800C;&#x4E14;&#x66F4;&#x7B80;&#x5355;.&#x6211;&#x4EEC;&#x901A;&#x8FC7;&#x8FD9;&#x9053;&#x9898;&#x7684;&#x63CF;&#x8FF0;.</p>
<pre><code>&#x5982;&#x679C;index=0&#x65F6;;&#x4EE3;&#x8868;&#x8981;&#x62A2;&#x7B2C;1&#x5BB6;,&#x90A3;&#x4E48;&#x4E4B;&#x540E;&#x80FD;&#x62A2;&#x7684;&#x5C31;&#x6709;{2,3,4,5,6...};
&#x5982;&#x679C;index=1&#x65F6;;&#x4EE3;&#x8868;&#x8981;&#x62A2;&#x7B2C;2&#x5BB6;,&#x90A3;&#x4E48;&#x4E4B;&#x540E;&#x80FD;&#x62A2;&#x7684;&#x5C31;&#x6709;{3,4,5,6,7...};
&#x5982;&#x679C;index=2&#x65F6;;&#x4EE3;&#x8868;&#x8981;&#x62A2;&#x7B2C;3&#x5BB6;,&#x90A3;&#x4E48;&#x4E4B;&#x540E;&#x80FD;&#x62A2;&#x7684;&#x5C31;&#x6709;{4,5,6,7,8...};
&#x5982;&#x679C;index=3&#x65F6;;&#x4EE3;&#x8868;&#x8981;&#x62A2;&#x7B2C;4&#x5BB6;,&#x90A3;&#x4E48;&#x4E4B;&#x540E;&#x80FD;&#x62A2;&#x7684;&#x5C31;&#x6709;{5,6,7,8,9...};
.
.
...
&#x5982;&#x679C;index=nums.length-2&#x65F6;;&#x4EE3;&#x8868;&#x8981;&#x62A2;&#x5012;&#x6570;&#x7B2C;2&#x5BB6;,&#x90A3;&#x4E48;&#x4E4B;&#x540E;&#x6CA1;&#x6709;&#x53EF;&#x4EE5;&#x62A2;&#x7684;&#x5BB6;;
&#x5982;&#x679C;index=nums.length-1&#x65F6;;&#x4EE3;&#x8868;&#x8981;&#x62A2;&#x5012;&#x6570;&#x7B2C;1&#x5BB6;,&#x90A3;&#x4E48;&#x4E4B;&#x540E;&#x6CA1;&#x6709;&#x53EF;&#x4EE5;&#x62A2;&#x7684;&#x5BB6;;
</code></pre>
<p>&#x5982;&#x679C;&#x6211;&#x4EEC;&#x7528;&#x6570;&#x7EC4;dp[]&#x6765;&#x8868;&#x793A;&#x62A2;&#x5230;&#x94B1;&#x7684;&#x603B;&#x6570;&#x6700;&#x5927;&#x503C;,&#x90A3;&#x4E48;dp[index],&#x5C31;&#x8868;&#x793A;&#x4ECE;&#x7B2C;0&#x5BB6;&#x62A2;&#x5230;&#x7B2C;index&#x5BB6;&#x7684;&#x62A2;&#x94B1;&#x603B;&#x6570;&#x6700;&#x5927;&#x503C;.</p>
<ol>
<li>&#x5F53;&#x53EA;&#x6709;1&#x5BB6;&#x65F6;,dp[0]=num[0],&#x6700;&#x5927;&#x503C;&#x5C31;&#x662F;result=dp[0],&#x56E0;&#x4E3A;&#x53EA;&#x6709;1&#x5BB6;&#x80FD;&#x62A2;;</li>
<li>&#x5F53;&#x53EA;&#x6709;2&#x5BB6;&#x65F6;,&#x90A3;&#x4E48;&#x62A2;&#x7684;&#x94B1;&#x53EA;&#x80FD;&#x5728;&#x5728;&#x8FD9;2&#x5BB6;&#x91CC;&#x9762;&#x9009;,dp[0]=num[0],dp[1]=num[1],&#x90A3;&#x4E48;result=Max(dp[0],dp[1]);</li>
<li>&#x5F53;&#x6709;3&#x5BB6;&#x65F6;,&#x5C31;&#x4F1A;&#x51FA;&#x73B0;2&#x79CD;&#x60C5;&#x51B5;,&#x62A2;&#x7B2C;&#x4E00;&#x5BB6;&#x548C;&#x7B2C;&#x4E09;&#x5BB6;,&#x6216;&#x8005;&#x53EA;&#x5F3A;&#x7B2C;&#x4E8C;&#x5BB6;.&#x90A3;&#x4E48;dp[2]&#x5C31;&#x6709;:$$result= \begin{cases}dp\left[ 0\right] +dp\left[ 2\right] \\ dp\left[ 1\right] \end{cases} $$<br>
result&#x5C31;&#x662F;&#x5728;&#x4EE5;&#x4E0A;&#x8FD9;2&#x79CD;&#x60C5;&#x51B5;&#x9009;&#x4E00;&#x4E2A;&#xFF0C;&#x5219;&#x662F;$$result=Max(dp[0]+dp[2],dp[1])$$</li>
<li>&#x5F53;&#x6709;4&#x5BB6;&#x65F6;&#xFF0C;&#x6211;&#x4EEC;&#x5C31;&#x53EF;&#x4EE5;&#x603B;&#x7ED3;&#x51FA;&#x4E00;&#x4E2A;&#x89C4;&#x5F8B;&#xFF0C;&#x62A2;&#x8FD9;4&#x5BB6;&#x6700;&#x591A;&#x7684;&#x94B1;&#xFF1A;<br>
$$result= \begin{cases}dp\left[ 0\right] +dp\left[ 2\right] \\ dp\left[ 1\right] +num\left[ 3\right]\end{cases} $$<br>
$$dp[3]=Max(dp[0]+dp[2],dp[1]+num[3])$$</li>
</ol>
<p>&#x90A3;&#x4E48;&#x5F53;&#x6709;N&#x5BB6;&#x65F6;&#xFF0C;&#x6211;&#x4EEC;&#x5219;&#x53EF;&#x4EE5;&#x8868;&#x793A;&#x4E3A;:<br>
$$result=Max(dp[N-1],dp[N-2])$$<br>
&#x6240;&#x6709;&#x6700;&#x540E;&#x7684;&#x4EE3;&#x7801;&#x4E3A;&#xFF1A;</p>
<pre><code>
class Solution {
    public int rob(int[] nums) {
      if (nums.length==0){
    	   return 0;
       }
       if (nums.length==1){
    	   return nums[0];
       }
       int[] dp=new int[nums.length+1];
       dp[0]=nums[0];
       dp[1]=Math.max(nums[1], nums[0]);
       for (int i=2;i&lt;nums.length;i++){
    	   dp[i]=Math.max(dp[i-1], dp[i-2]+nums[i]);
       }
       return Math.max(dp[nums.length-1], dp[nums.length-2]);
    }
}
</code></pre>
<!--kg-card-end: markdown-->]]></content:encoded></item><item><title><![CDATA[[翻译]Blink是如何工作的(未完)]]></title><description><![CDATA[<!--kg-card-begin: markdown--><p>&#x5728;Blink&#x4E0A;&#x5DE5;&#x4F5C;&#x4E0D;&#x662F;&#x4EF6;&#x5BB9;&#x6613;&#x7684;&#x4E8B;.Blink&#x6709;&#x5F88;&#x591A;&#x4E13;&#x6709;&#x7684;&#x6982;&#x5FF5;,&#x5E76;&#x4E14;&#x6709;&#x4E00;&#x5957;&#x4E3A;&#x4E86;&#x5B9E;&#x73B0;&#x5FEB;&#x901F;&#x6E32;&#x67D3;&#x5F15;&#x64CE;&#x800C;&#x5F15;&#x5165;&#x7684;&#x7F16;&#x7801;&#x89C4;&#x8303;,&#x8FD9;&#x4E2A;&#x5BF9;&#x4E8E;&#x65B0;&#x5F00;</p>]]></description><link>http://www.lichen.in/blink/</link><guid isPermaLink="false">5b8f8c0102b60c7f8b23f6ea</guid><dc:creator><![CDATA[lichen]]></dc:creator><pubDate>Fri, 25 Aug 2023 20:37:37 GMT</pubDate><content:encoded><![CDATA[<!--kg-card-begin: markdown--><p>&#x5728;Blink&#x4E0A;&#x5DE5;&#x4F5C;&#x4E0D;&#x662F;&#x4EF6;&#x5BB9;&#x6613;&#x7684;&#x4E8B;.Blink&#x6709;&#x5F88;&#x591A;&#x4E13;&#x6709;&#x7684;&#x6982;&#x5FF5;,&#x5E76;&#x4E14;&#x6709;&#x4E00;&#x5957;&#x4E3A;&#x4E86;&#x5B9E;&#x73B0;&#x5FEB;&#x901F;&#x6E32;&#x67D3;&#x5F15;&#x64CE;&#x800C;&#x5F15;&#x5165;&#x7684;&#x7F16;&#x7801;&#x89C4;&#x8303;,&#x8FD9;&#x4E2A;&#x5BF9;&#x4E8E;&#x65B0;&#x5F00;&#x53D1;&#x8005;&#x6765;&#x8BF4;&#x5E76;&#x4E0D;&#x662F;&#x6613;&#x4E8B;.&#x5373;&#x4F7F;&#x662F;&#x7ECF;&#x9A8C;&#x4E30;&#x5BCC;&#x7684;Blink&#x5F00;&#x53D1;&#x4EBA;&#x5458;&#x4E5F;&#x4E0D;&#x5BB9;&#x6613;,&#x56E0;&#x4E3A;Blink&#x975E;&#x5E38;&#x5E9E;&#x5927;,&#x5BF9;&#x6027;&#x80FD;,&#x5185;&#x5B58;&#x548C;&#x5B89;&#x5168;&#x6027;&#x6781;&#x4E3A;&#x654F;&#x611F;.</p>
<p>&#x8FD9;&#x7BC7;&#x6587;&#x6863;&#x7684;&#x76EE;&#x7684;&#x662F;&#x5E2E;&#x52A9;Blink&#x7684;&#x5F00;&#x53D1;&#x8005;&#x5FEB;&#x901F;&#x719F;&#x6089;&#x67B6;&#x6784;:</p>
<ul>
<li>&#x8BE5;&#x6587;&#x6863;&#x5E76;&#x4E0D;&#x662F;&#x8BB2;&#x8FF0;Blink&#x7684;&#x8BE6;&#x7EC6;&#x67B6;&#x6784;&#x548C;&#x7F16;&#x7801;&#x89C4;&#x5219;&#x6559;&#x7A0B;.&#x76F8;&#x53CD;,&#x8BE5;&#x6587;&#x6863;&#x7B80;&#x660E;&#x7684;&#x63CF;&#x8FF0;&#x4E86;Blink&#x7684;&#x77ED;&#x671F;&#x5185;&#x4E0D;&#x592A;&#x53EF;&#x80FD;&#x53D1;&#x751F;&#x53D8;&#x5316;&#x57FA;&#x672C;&#x9762;,&#x5E76;&#x6307;&#x51FA;&#x5982;&#x679C;&#x4F60;&#x60F3;&#x4E86;&#x89E3;&#x66F4;&#x591A;&#x4FE1;&#x606F;,&#x4F60;&#x53EF;&#x4EE5;&#x9605;&#x8BFB;&#x7684;&#x8D44;&#x6E90;&#x6709;&#x54EA;&#x4E9B;&#x3002;</li>
<li>&#x8BE5;&#x6587;&#x6863;&#x6CA1;&#x6709;&#x89E3;&#x91CA;&#x5177;&#x4F53;&#x7684;&#x67D0;&#x4E9B;&#x529F;&#x80FD;&#xFF08;&#x4F8B;&#x5982;&#xFF0C;ServiceWorkers&#xFF0C;&#x7F16;&#x8F91;&#xFF09;.&#x76F8;&#x53CD;,&#x8BE5;&#x6587;&#x6863;&#x89E3;&#x91CA;&#x4E86;&#x57FA;&#x672C;&#x529F;&#x80FD;(&#x4F8B;&#x5982;&#xFF0C;&#x5B58;&#x50A8;&#x5668;&#x7BA1;&#x7406;&#xFF0C;V8 API)&#x3002;</li>
</ul>
<p><a href="#What_Blink_does">Blink&#x662F;&#x5E72;&#x4EC0;&#x4E48;&#x7684;?</a></p>
<p><a href="#Process/thread_architecture">&#x8FDB;&#x7A0B;/&#x7EBF;&#x7A0B;&#x67B6;&#x6784;</a></p>
<ul>
<li>
<p><a href="#Processes">&#x8FDB;&#x7A0B;</a></p>
</li>
<li>
<p><a href="#Threads">&#x7EBF;&#x7A0B;</a></p>
</li>
<li>
<p><a href="#Initialization_of_Blink">&#x521D;&#x59CB;&#x5316;Blink</a></p>
</li>
</ul>
<p><a href="#Directory_structure">&#x76EE;&#x5F55;&#x7ED3;&#x6784;</a></p>
<ul>
<li><a href="#Content_public_APIs_and_Blink_public_APIs">Content&#x516C;&#x5F00;API&#x548C;blink&#x516C;&#x5F00;API</a></li>
<li><a href="Directory_structure_and_dependencies">&#x76EE;&#x5F55;&#x7ED3;&#x6784;&#x548C;&#x4F9D;&#x8D56;</a></li>
<li><a href="#WTF">Web Template Framework(WTF)</a></li>
</ul>
<p><a href="#Memory_management">&#x5185;&#x5B58;&#x7BA1;&#x7406;</a></p>
<p><a href="#Task_scheduling">&#x4EFB;&#x52A1;&#x8C03;&#x5EA6;</a></p>
<p><a href="#Page,Frame,Document,DOMWindow_etc">Page, Frame, Document, DOMWindow etc</a></p>
<ul>
<li><a href="#Concepts">&#x6982;&#x5FF5;</a></li>
<li><a href="#Out-of-Process_iframes">&#x8FDB;&#x7A0B;&#x5916;&#x7684;iframe(OOPIF)</a></li>
<li>[&#x79FB;&#x9664;Frame/Document](#Detached Frame_/_Document)</li>
<li><a href="#Web_IDL_bindings">&#x7F51;&#x9875;&#x63A5;&#x53E3;&#x5B9A;&#x4E49;&#x8BED;&#x8A00;&#x7ED1;&#x5B9A;(Web IDL bindings)</a></li>
</ul>
<p><a href="#V8_and_Blink">V8&#x548C;Blink</a></p>
<ul>
<li><a href="#Isolate,_Context,_World">Isolate, Context, World</a></li>
<li><a href="#V8_APIs">V8&#x7684;API</a></li>
<li><a href="#V8_wrappers">V8&#x7684;&#x5305;&#x88C5;&#x7C7B;&#x4EEC;</a></li>
</ul>
<p><a href="#Rendering_pipeline">&#x6E32;&#x67D3;&#x6D41;&#x6C34;&#x7EBF;</a></p>
<p><a href="#Question?">&#x95EE;&#x9898;?</a></p>
<h5 id="What_Blink_does">Blink&#x662F;&#x5E72;&#x4EC0;&#x4E48;&#x7684;?</h5>
<p><a href="https://www.chromium.org/blink?ref=lichen.in">Blink</a>&#x662F;web&#x5E73;&#x53F0;&#x7684;&#x4E00;&#x4E2A;&#x6E32;&#x67D3;&#x5F15;&#x64CE;.&#x901A;&#x4FD7;&#x7684;&#x8BF4;,Blink&#x5B9E;&#x73B0;&#x4E86;&#x80FD;&#x5728;&#x6D4F;&#x89C8;&#x5668;&#x91CC;&#x5448;&#x73B0;&#x6240;&#x6709;&#x5185;&#x5BB9;&#x7684;&#x80FD;&#x529B;:</p>
<ul>
<li>&#x5B9E;&#x73B0;&#x4E86;&#x6D4F;&#x89C8;&#x5668;&#x5E73;&#x53F0;&#x7684;&#x89C4;&#x8303;(&#x4F8B;&#x5982;html&#x6807;&#x5FD7;).&#x5305;&#x62EC;DOM,CSS&#x548C;Web IDL.</li>
<li>&#x5D4C;&#x5165;&#x4E86;V8&#x5F15;&#x64CE;&#x548C;&#x6267;&#x884C;JavaScript</li>
<li>&#x4ECE;&#x5E95;&#x5C42;&#x7F51;&#x7EDC;&#x6808;&#x4E2D;&#x8BF7;&#x6C42;&#x8D44;&#x6E90;</li>
<li>&#x6784;&#x5EFA;DOM&#x6811;</li>
<li>&#x8BA1;&#x7B97;&#x6837;&#x5F0F;&#x548C;&#x5E03;&#x5C40;</li>
<li>&#x5D4C;&#x5165;&#x4E86;chrome&#x7684;&#x6392;&#x7248;&#x5668;&#x548C;&#x56FE;&#x5F62;&#x7ED8;&#x5236;</li>
</ul>
<p>blink&#x901A;&#x8FC7;Content public APIs&#x5D4C;&#x5165;&#x4E86;&#x8BB8;&#x591A;&#x7B2C;&#x4E09;&#x65B9;&#x7684;&#x6D4F;&#x89C8;&#x5668;(&#x4F8B;&#x5982;chromium,android webview,Opear).</p>
<p><img src="http://www.lichen.in/content/images/2018/10/Untitled-Diagram.png" alt="Untitled-Diagram" loading="lazy"><br>
&#x4ECE;&#x4EE3;&#x7801;&#x5E93;&#x7684;&#x89D2;&#x5EA6;&#x770B;,&quot;Blink&quot;&#x901A;&#x5E38;&#x662F;&#x6307;//third_party/blink/.&#x4ECE;&#x9879;&#x76EE;&#x89D2;&#x5EA6;&#x770B;,&quot;Blink&quot;&#x901A;&#x5E38;&#x662F;&#x6307;&#x5B9E;&#x73B0;&#x9879;&#x76EE;&#x7684;&#x529F;&#x80FD;.&#x5B9E;&#x73B0;Web&#x5E73;&#x53F0;&#x529F;&#x80FD;&#x7684;&#x4EE3;&#x7801;&#x8303;&#x56F4;&#x4E3A;:</p>
<ul>
<li>//third_party/blink/</li>
<li>//content/renderer/</li>
<li>//content/browser/</li>
<li>&#x5176;&#x4ED6;&#x5730;&#x65B9;&#x3002;</li>
</ul>
<h5 id="Process/thread_architecture">&#x8FDB;&#x7A0B;/&#x7EBF;&#x7A0B;&#x67B6;&#x6784;</h5>
<!--kg-card-end: markdown-->]]></content:encoded></item><item><title><![CDATA[[算法]堆排序]]></title><description><![CDATA[<!--kg-card-begin: markdown--><p>&#x5806;&#x6392;&#x5E8F;&#x7684;&#x4E3B;&#x8981;&#x6B65;&#x9AA4;&#x5206;&#x4E3A;&#x4E09;&#x90E8;&#x5206;:</p>
<ol>
<li>&#x5EFA;&#x5806;</li>
<li>&#x7EF4;&#x6301;&#x5806;&#x7684;&#x6027;&#x8D28;</li>
<li>&#x6392;&#x5E8F;</li>
</ol>
<p>&#x9996;&#x5148;&#x662F;&#x5EFA;&#x5806;,&#x5EFA;&#x5806;&#x7684;&#x4E3B;&#x8981;&#x76EE;&#x7684;&#x662F;&#x5EFA;&#x7ACB;&#x4E00;&#x4E2A;&#x6700;&#x5927;&#x5806;,&#x8FD9;&#x6837;&#x6211;&#x4EEC;&#x5C31;&#x53EF;&#x4EE5;</p>]]></description><link>http://www.lichen.in/suan-fa-dui-pai-xu/</link><guid isPermaLink="false">5badddcf02b60c7f8b23f6fa</guid><dc:creator><![CDATA[lichen]]></dc:creator><pubDate>Fri, 25 Aug 2023 20:37:23 GMT</pubDate><content:encoded><![CDATA[<!--kg-card-begin: markdown--><p>&#x5806;&#x6392;&#x5E8F;&#x7684;&#x4E3B;&#x8981;&#x6B65;&#x9AA4;&#x5206;&#x4E3A;&#x4E09;&#x90E8;&#x5206;:</p>
<ol>
<li>&#x5EFA;&#x5806;</li>
<li>&#x7EF4;&#x6301;&#x5806;&#x7684;&#x6027;&#x8D28;</li>
<li>&#x6392;&#x5E8F;</li>
</ol>
<p>&#x9996;&#x5148;&#x662F;&#x5EFA;&#x5806;,&#x5EFA;&#x5806;&#x7684;&#x4E3B;&#x8981;&#x76EE;&#x7684;&#x662F;&#x5EFA;&#x7ACB;&#x4E00;&#x4E2A;&#x6700;&#x5927;&#x5806;,&#x8FD9;&#x6837;&#x6211;&#x4EEC;&#x5C31;&#x53EF;&#x4EE5;&#x4FDD;&#x8BC1;&#x5806;&#x9876;&#x7684;&#x5143;&#x7D20;&#x4E00;&#x5B9A;&#x662F;&#x8FD9;&#x4E2A;&#x6570;&#x7EC4;&#x4E2D;&#x6700;&#x5927;&#x7684;&#x5143;&#x7D20;.</p>
<pre><code>void buildHeap(int *array, int size)
{
    for (int i = size / 2; i &gt;= 0; i--)
    {
        maxHeapify(array, i, size);  //&#x7EF4;&#x6301;&#x6700;&#x5927;&#x5806;&#x6027;&#x8D28;
    }
}
</code></pre>
<p>&#x5176;&#x6B21;&#x662F;&#x7EF4;&#x6301;&#x6700;&#x5927;&#x5806;&#x6027;&#x8D28;,&#x5176;&#x8FC7;&#x7A0B;&#x5982;&#x4E0B;:</p>
<ol>
<li>&#x6BD4;&#x8F83;&#x5F53;&#x524D;&#x8282;&#x70B9;(&#x7236;&#x8282;&#x70B9;)&#x548C;&#x81EA;&#x5DF1;&#x7684;2&#x4E2A;&#x5B50;&#x8282;&#x70B9;(&#x53EF;&#x80FD;&#x662F;1&#x4E2A;)&#x7684;&#x5927;&#x5C0F;.</li>
<li>&#x5C06;3&#x4E2A;&#x8282;&#x70B9;&#x4E2D;&#x6700;&#x5927;&#x503C;&#x7684;&#x70B9;&#x4E0E;&#x5F53;&#x524D;&#x8282;&#x70B9;&#x4EA4;&#x6362;&#x4F4D;&#x7F6E;.</li>
<li>&#x5982;&#x679C;&#x4EA7;&#x751F;&#x4E86;&#x8282;&#x70B9;&#x4EA4;&#x6362;,&#x90A3;&#x4E48;&#x7EE7;&#x7EED;&#x4EE5;&#x4EA4;&#x6362;&#x540E;&#x7684;&#x8282;&#x70B9;&#x4F5C;&#x4E3A;&#x7236;&#x8282;&#x70B9;&#x7EE7;&#x7EED;&#x6267;&#x884C;maxHeapify.</li>
<li>&#x76F4;&#x5230;&#x4E0D;&#x518D;&#x4EA7;&#x751F;&#x8282;&#x70B9;&#x4F4D;&#x7F6E;&#x4EA4;&#x6362;.</li>
</ol>
<pre><code>void maxHeapify(int *array, int index, int size)
{
    int l = left(index);
    int r = right(index);
    int largest;
    if (l &lt; size &amp;&amp; array[l] &gt; array[index])
    {
        largest = l;
    }
    else
    {
        largest = index;
    }

    if (r &lt; size &amp;&amp; array[r] &gt; array[largest])
    {
        largest = r;
    }
    if (largest != index)
    {
        int temp = array[largest];
        array[largest] = array[index];
        array[index] = temp;
        maxHeapify(array, largest, size);
    }
}
</code></pre>
<p>&#x6700;&#x540E;&#x5219;&#x662F;&#x6392;&#x5E8F;&#x8FC7;&#x7A0B;,&#x56E0;&#x4E3A;&#x5728;&#x5EFA;&#x5806;&#x548C;&#x7EF4;&#x6301;&#x5806;&#x6301;&#x7EED;&#x540E;,&#x5DF2;&#x7ECF;&#x4EA7;&#x751F;&#x4E86;1&#x4E2A;&#x6700;&#x5927;&#x5806;,&#x90A3;&#x4E48;&#x5269;&#x4E0B;&#x7684;&#x8FC7;&#x7A0B;&#x53EA;&#x9700;&#x8981;&#x5C06;&#x6570;&#x7EC4;&#x7684;&#x6700;&#x540E;1&#x4F4D;&#x548C;&#x6839;&#x8282;&#x70B9;&#x4EA4;&#x6362;&#x4F4D;&#x7F6E;,&#x5C06;&#x6570;&#x7EC4;&#x7684;length-1,&#x7136;&#x540E;&#x7EE7;&#x7EED;&#x7EF4;&#x6301;&#x5806;&#x7684;&#x6027;&#x8D28;&#x540E;,&#x90A3;&#x4E48;&#x5C31;&#x53C8;&#x4EA7;&#x751F;&#x4E86;1&#x4E2A;&#x6700;&#x5927;&#x5806;,&#x5982;&#x6B64;&#x5FAA;&#x73AF;&#x76F4;&#x5230;&#x53EA;&#x5269;&#x4E0B;1&#x4E2A;&#x5143;&#x7D20;&#x7684;&#x65F6;&#x5019;.&#x6392;&#x5E8F;&#x8FC7;&#x7A0B;&#x5982;&#x4E0B;&#x56FE;:<br>
<img src="http://www.lichen.in/content/images/2018/09/MacHi-2018-09-28-19-31-17.png" alt="MacHi-2018-09-28-19-31-17" loading="lazy"><br>
<img src="http://www.lichen.in/content/images/2018/09/MacHi-2018-09-28-19-39-19.png" alt="MacHi-2018-09-28-19-39-19" loading="lazy"><br>
&#x6392;&#x5E8F;&#x4EE3;&#x7801;&#x5C31;&#x5F88;&#x7B80;&#x5355;&#x4E86;,&#x5982;&#x4E0B;:</p>
<pre><code>void heapSort(int *array, int size)
{
    buildHeap(array, size);
    int length = size;
    for (int i = length - 1; i &gt;= 1; i--)
    {
        int temp = array[i];
        array[i] = array[0];
        array[0] = temp;
        size -= 1;
        maxHeapify(array, 0, size);
    }
}
</code></pre>
<p>&#x6700;&#x540E;&#x9644;&#x4E0A;&#x5B8C;&#x6574;&#x4EE3;&#x7801;</p>
<pre><code>#include &quot;iostream&quot;
using namespace std;

int parent(int i)
{
    return i / 2;
}

int left(int i)
{
    return i * 2 + 1;
}

int right(int i)
{
    return i * 2 + 2;
}

void maxHeapify(int *array, int index, int size)
{
    int l = left(index);
    int r = right(index);
    int largest;
    if (l &lt; size &amp;&amp; array[l] &gt; array[index])
    {
        largest = l;
    }
    else
    {
        largest = index;
    }

    if (r &lt; size &amp;&amp; array[r] &gt; array[largest])
    {
        largest = r;
    }
    if (largest != index)
    {
        int temp = array[largest];
        array[largest] = array[index];
        array[index] = temp;
        maxHeapify(array, largest, size);
    }
}

void buildHeap(int *array, int size)
{
    for (int i = size / 2; i &gt;= 0; i--)
    {
        maxHeapify(array, i, size);
    }
}

void heapSort(int *array, int size)
{
    buildHeap(array, size);
    int length = size;
    for (int i = length - 1; i &gt;= 1; i--)
    {
        int temp = array[i];
        array[i] = array[0];
        array[0] = temp;
        size -= 1;
        maxHeapify(array, 0, size);
    }
}

int main()
{
    int array[] = {4, 1, 3, 2, 16, 9, 10, 14, 8, 7};
    int size = sizeof(array) / sizeof(array[0]);
    heapSort(array, size);

    for (int i = 0; i &lt; sizeof(array) / sizeof(array[0]); i++)
    {
        cout &lt;&lt; array[i] &lt;&lt; endl;
    }
    return 0;
}
</code></pre>
<!--kg-card-end: markdown--><p>&#x5806;&#x6392;&#x5E8F;&#x7684;&#x65F6;&#x95F4;&#x590D;&#x6742;&#x5EA6;&#x5206;&#x6790;:</p><p> &#x65F6;&#x95F4;&#x590D;&#x6742;&#x5EA6;&#x4E3A;O(nlgn).&#x800C;&#x4E14;&#x4E3A;<strong>&#x539F;&#x5740;&#x6392;&#x5E8F;&#x7B97;&#x6CD5;</strong>(&#x5982;&#x679C;&#x8F93;&#x5165;&#x6570;&#x7EC4;&#x4E2D;&#x4EC5;&#x6709;&#x5E38;&#x6570;&#x4E2A;&#x6570;&#x5143;&#x7D20;&#x9700;&#x8981;&#x5728;&#x6392;&#x5E8F;&#x8FC7;&#x7A0B;&#x5B58;&#x50A8;&#x5728;&#x6570;&#x636E;&#x4E4B;&#x5916;,&#x5219;&#x79F0;&#x6392;&#x5E8F;&#x7B97;&#x6CD5;&#x662F;&#x539F;&#x5740;&#x7684;).&#x8FD9;&#x91CC;&#x5FEB;&#x901F;&#x6392;&#x5E8F;&#x662F;&#x539F;&#x5740;&#x7684;,&#x4F46;&#x5F52;&#x5E76;&#x6392;&#x5E8F;&#x4E0D;&#x662F;&#x539F;&#x5740;&#x7684;,&#x56E0;&#x4E3A;&#x5728;&#x5408;&#x5E76;&#x8FC7;&#x7A0B;&#x4E2D;&#x6709;&#x989D;&#x5916;&#x7684;&#x6570;&#x7EC4;&#x5B58;&#x50A8;.</p><p>heapSort&#x5728;&#x5EFA;&#x7ACB;&#x521D;&#x59CB;&#x6700;&#x5927;&#x5806;&#x540E;,&#x5B83;&#x7684;&#x65F6;&#x95F4;&#x590D;&#x6742;&#x5EA6;&#x4E3A;O(n),&#x800C;length-1&#x6B21;&#x7684;&#x8C03;&#x7528;maxHeapify,&#x6BCF;&#x6B21;&#x8C03;&#x7528;&#x65F6;&#x95F4;&#x590D;&#x6742;&#x5EA6;&#x4E3A;O(lgn).&#x6240;&#x4EE5;&#x603B;&#x65F6;&#x95F4;&#x590D;&#x6742;&#x5EA6;&#x4F4D;O(nlgn);</p>]]></content:encoded></item><item><title><![CDATA[[翻译]Chromium 的多进程架构]]></title><description><![CDATA[<p>&#x8FD9;&#x8FB9;&#x6587;&#x7AE0;&#x8BB2;&#x7684;&#x5185;&#x5BB9;&#x4E3A;chromium&#x7684;&#x4E0A;&#x5C42;&#x67B6;&#x6784;.</p><!--kg-card-begin: markdown--><h1 id>&#x95EE;&#x9898;</h1>
<p>&#x6784;&#x5EFA;&#x4E00;&#x4E2A;&#x4E0D;&#x5D29;&#x6E83;&#x6216;&#x8005;&#x7EDD;&#x5BF9;&#x5B89;&#x5168;&#x7684;&#x6E32;&#x67D3;&#x5F15;&#x64CE;&#x51E0;&#x4E4E;&#x662F;&#x4E0D;&#x53EF;&#x80FD;&#x7684;.</p>
<p>&#x5728;2006&#x5E74;&#x5DE6;&#x53F3;,&#x6D4F;&#x89C8;&#x5668;</p>]]></description><link>http://www.lichen.in/fan-yi-chromium-de-duo-jin-cheng-jia-gou/</link><guid isPermaLink="false">5b8e3cbe038d3232d29da2ee</guid><dc:creator><![CDATA[lichen]]></dc:creator><pubDate>Fri, 25 Aug 2023 20:37:12 GMT</pubDate><content:encoded><![CDATA[<p>&#x8FD9;&#x8FB9;&#x6587;&#x7AE0;&#x8BB2;&#x7684;&#x5185;&#x5BB9;&#x4E3A;chromium&#x7684;&#x4E0A;&#x5C42;&#x67B6;&#x6784;.</p><!--kg-card-begin: markdown--><h1 id>&#x95EE;&#x9898;</h1>
<p>&#x6784;&#x5EFA;&#x4E00;&#x4E2A;&#x4E0D;&#x5D29;&#x6E83;&#x6216;&#x8005;&#x7EDD;&#x5BF9;&#x5B89;&#x5168;&#x7684;&#x6E32;&#x67D3;&#x5F15;&#x64CE;&#x51E0;&#x4E4E;&#x662F;&#x4E0D;&#x53EF;&#x80FD;&#x7684;.</p>
<p>&#x5728;2006&#x5E74;&#x5DE6;&#x53F3;,&#x6D4F;&#x89C8;&#x5668;&#x7684;&#x72B6;&#x6001;&#x7C7B;&#x4F3C;&#x4E8E;&#x8FC7;&#x53BB;&#x7684;&#x5355;&#x7528;&#x6237;,&#x534F;&#x4F5C;&#x5F0F;&#x64CD;&#x4F5C;&#x7CFB;&#x7EDF;.&#x7531;&#x4E8E;&#x4E00;&#x4E9B;&#x7A0B;&#x5E8F;&#x7684;&#x9519;&#x8BEF;&#x884C;&#x4E3A;&#x53EF;&#x80FD;&#x5BFC;&#x81F4;&#x6574;&#x4E2A;&#x7CFB;&#x7EDF;&#x90FD;&#x5D29;&#x6E83;,&#x540C;&#x6837;&#x67D0;&#x4E9B;&#x9875;&#x9762;&#x7684;&#x9519;&#x8BEF;&#x64CD;&#x4F5C;&#x4F1A;&#x4F7F;&#x6574;&#x4E2A;&#x6D4F;&#x89C8;&#x5668;&#x5954;&#x6E83;,&#x8FD9;&#x53EA;&#x662F;&#x4E00;&#x4E2A;&#x9875;&#x9762;&#x7684;&#x9519;&#x8BEF;&#x6216;&#x8005;&#x63D2;&#x4EF6;&#x7684;bug&#x5C31;&#x4F1A;&#x5BFC;&#x81F4;&#x6574;&#x4E2A;&#x6D4F;&#x89C8;&#x5668;&#x5173;&#x95ED;&#x548C;&#x6240;&#x6709;&#x7684;Tabs.</p>
<p>&#x73B0;&#x5728;&#x7684;&#x64CD;&#x4F5C;&#x7CFB;&#x7EDF;&#x5F80;&#x5F80;&#x90FD;&#x66F4;&#x5065;&#x58EE;,&#x56E0;&#x4E3A;&#x5B83;&#x5C06;&#x4E0D;&#x540C;&#x7684;&#x7A0B;&#x5E8F;&#x653E;&#x5230;&#x4E86;&#x5F7C;&#x6B64;&#x9694;&#x79BB;&#x7684;&#x5355;&#x72EC;&#x8FDB;&#x7A0B;&#x4E2D;.&#x4E00;&#x4E2A;&#x5E94;&#x7528;&#x5D29;&#x6E83;&#x901A;&#x5E38;&#x4E0D;&#x4F1A;&#x5F71;&#x54CD;&#x5176;&#x4ED6;&#x5E94;&#x7528;&#x6216;&#x8005;&#x6574;&#x4E2A;&#x7CFB;&#x7EDF;,&#x5E76;&#x4E14;&#x6BCF;&#x4E2A;&#x7528;&#x6237;&#x8BBF;&#x95EE;&#x5176;&#x4ED6;&#x7528;&#x6237;&#x7684;&#x6570;&#x636E;&#x662F;&#x53D7;&#x9650;&#x7684;.</p>
<h1 id>&#x67B6;&#x6784;&#x6982;&#x89C8;</h1>
<p>&#x6211;&#x4EEC;&#x5BF9;&#x6D4F;&#x89C8;&#x5668;&#x7684;Tab&#x9875;&#x4F7F;&#x7528;&#x5355;&#x72EC;&#x8FDB;&#x7A0B;,&#x53EF;&#x4EE5;&#x907F;&#x514D;&#x6574;&#x4E2A;&#x5E94;&#x7528;&#x53D7;&#x5230;&#x6E32;&#x67D3;&#x5F15;&#x64CE;&#x7684;bug&#x6216;&#x8005;&#x5C0F;&#x6545;&#x969C;&#x7684;&#x5F71;&#x54CD;.&#x6211;&#x4EEC;&#x4E5F;&#x9650;&#x5236;&#x6BCF;&#x4E2A;&#x6E32;&#x67D3;&#x5F15;&#x64CE;&#x8FDB;&#x7A0B;&#x8BBF;&#x95EE;&#x5176;&#x4ED6;&#x8FDB;&#x7A0B;&#x548C;&#x7CFB;&#x7EDF;&#x7684;&#x5176;&#x4ED6;&#x90E8;&#x5206;.&#x8FD9;&#x4E3A;&#x6D4F;&#x89C8;&#x5668;&#x5E26;&#x6765;&#x4E86;&#x5185;&#x5B58;&#x4FDD;&#x62A4;&#x548C;&#x8BBF;&#x95EE;&#x63A7;&#x5236;&#x64CD;&#x4F5C;&#x7CFB;&#x7EDF;&#x5E26;&#x6765;&#x4E86;&#x597D;&#x5904;.</p>
<p>&#x6211;&#x4EEC;&#x5C06;&#x8FD0;&#x884C;UI&#x7684;&#x4E3B;&#x7EBF;&#x7A0B;&#x548C;&#x7BA1;&#x7406;Tabs&#x548C;&#x63D2;&#x4EF6;&#x8FDB;&#x7A0B;&#x7684;&#x4F5C;&#x4E3A;&quot;&#x6D4F;&#x89C8;&#x5668;&#x8FDB;&#x7A0B;&quot;&#x6216;&#x8005;&quot;&#x6D4F;&#x89C8;&#x5668;&quot;.&#x540C;&#x6837;&#x7684;,&#x7279;&#x5B9A;Tab&#x7684;&#x8FDB;&#x7A0B;&#x79F0;&#x4E3A;&quot;&#x6E32;&#x67D3;&#x8FDB;&#x7A0B;&quot;&#x6216;&#x8005;&quot;&#x6E32;&#x67D3;&#x5668;&quot;.&#x6E32;&#x67D3;&#x5668;&#x4F7F;&#x7528;Blink&#x5F00;&#x6E90;&#x5E03;&#x5C40;&#x5F15;&#x64CE;&#x6765;&#x89E3;&#x91CA;&#x548C;&#x5E03;&#x5C40;HTML.</p>
<p><img src="http://www.lichen.in/content/images/2018/09/arch.png" alt="arch" loading="lazy"></p>
<h1 id>&#x7BA1;&#x7406;&#x6E32;&#x67D3;&#x5F15;&#x64CE;</h1>
<p>&#x6BCF;&#x4E2A;&#x6E32;&#x67D3;&#x8FC7;&#x7A0B;&#x90FD;&#x6709;&#x4E00;&#x4E2A;&#x5168;&#x5C40;RenderProcess&#x5BF9;&#x8C61;&#xFF0C;&#x8BE5;&#x5BF9;&#x8C61;&#x7BA1;&#x7406;&#x4E0E;&#x7236;&#x6D4F;&#x89C8;&#x5668;&#x8FDB;&#x7A0B;&#x7684;&#x901A;&#x4FE1;&#x5E76;&#x7EF4;&#x62A4;&#x5168;&#x5C40;&#x72B6;&#x6001;&#x3002; &#x6D4F;&#x89C8;&#x5668;&#x4E3A;&#x6BCF;&#x4E2A;&#x6E32;&#x67D3;&#x8FDB;&#x7A0B;&#x7EF4;&#x62A4;&#x4E00;&#x4E2A;&#x76F8;&#x5E94;&#x7684;RenderProcessHost&#xFF0C;&#x5B83;&#x7BA1;&#x7406;&#x6E32;&#x67D3;&#x5668;&#x7684;&#x6D4F;&#x89C8;&#x5668;&#x72B6;&#x6001;&#x548C;&#x901A;&#x4FE1;&#x3002; &#x6D4F;&#x89C8;&#x5668;&#x548C;&#x6E32;&#x67D3;&#x5668;&#x4F7F;&#x7528;Chromium&#x7684;IPC&#x7CFB;&#x7EDF;&#x8FDB;&#x884C;&#x901A;&#x4FE1;&#x3002;</p>
<h1 id>&#x7BA1;&#x7406;&#x89C6;&#x56FE;</h1>
<p>&#x6BCF;&#x4E00;&#x4E2A;Tab&#x7684;&#x6E32;&#x67D3;&#x5F15;&#x64CE;&#x90FD;&#x81F3;&#x5C11;&#x6709;&#x4E00;&#x4E2A;RenderView&#x5BF9;&#x8C61;,&#x7531;RenderProcess&#x7BA1;&#x7406;.&#x76F8;&#x5E94;&#x7684;RenderProcessHost&#x7EF4;&#x62A4;&#x7740;&#x4E0E;&#x6E32;&#x67D3;&#x5668;&#x4E2D;&#x6BCF;&#x4E2A;&#x89C6;&#x56FE;&#x5BF9;&#x5E94;&#x7684;RenderViewHost. &#x6BCF;&#x4E2A;&#x89C6;&#x56FE;&#x90FD;&#x6709;&#x4E00;&#x4E2A;&#x89C6;&#x56FE;ID,&#x7528;&#x4E8E;&#x533A;&#x5206;&#x540C;&#x4E00;&#x6E32;&#x67D3;&#x5668;&#x4E2D;&#x7684;&#x591A;&#x4E2A;&#x89C6;&#x56FE;.&#x6BCF;&#x4E2A;&#x6E32;&#x67D3;&#x8FC7;&#x7A0B;&#x90FD;&#x6709;&#x4E00;&#x4E2A;&#x6216;&#x591A;&#x4E2A;RenderView&#x5BF9;&#x8C61;&#xFF0C;&#x7531;RenderProcess&#x7BA1;&#x7406;&#xFF0C;&#x5BF9;&#x5E94;&#x4E8E;&#x5185;&#x5BB9;&#x9009;&#x9879;&#x5361;&#x3002; &#x76F8;&#x5E94;&#x7684;RenderProcessHost&#x7EF4;&#x62A4;&#x4E0E;&#x6E32;&#x67D3;&#x5668;&#x4E2D;&#x6BCF;&#x4E2A;&#x89C6;&#x56FE;&#x5BF9;&#x5E94;&#x7684;RenderViewHost.&#x6BCF;&#x4E2A;&#x89C6;&#x56FE;&#x90FD;&#x6709;&#x4E00;&#x4E2A;&#x89C6;&#x56FE;ID&#xFF0C;&#x7528;&#x4E8E;&#x533A;&#x5206;&#x540C;&#x4E00;&#x6E32;&#x67D3;&#x5668;&#x4E2D;&#x7684;&#x591A;&#x4E2A;&#x89C6;&#x56FE;.&#x8FD9;&#x4E9B;ID&#x5728;&#x540C;&#x4E00;&#x4E2A;&#x6E32;&#x67D3;&#x5668;&#x4E2D;&#x662F;&#x552F;&#x4E00;&#x7684;,&#x4F46;&#x5728;&#x6574;&#x4E2A;&#x6D4F;&#x89C8;&#x5668;&#x4E2D;&#x4E0D;&#x662F;&#x552F;&#x4E00;&#x7684;,&#x56E0;&#x6B64;&#x8BC6;&#x522B;&#x89C6;&#x56FE;&#x9700;&#x8981;RenderProcessHost&#x548C;&#x89C6;&#x56FE;ID.&#x4ECE;&#x6D4F;&#x89C8;&#x5668;&#x5230;&#x7279;&#x5B9A;Tab&#x7684;&#x901A;&#x884C;&#x662F;&#x901A;&#x8FC7;&#x8FD9;&#x4E9B;RenderViewHost&#x5BF9;&#x8C61;&#x5B8C;&#x6210;&#x7684;.&#x8FD9;&#x4E9B;RenderProcessHost&#x5BF9;&#x8C61;&#x77E5;&#x9053;&#x5982;&#x4F55;&#x5C06;&#x6D88;&#x606F;&#x53D1;&#x9001;&#x7ED9;RenderProcess&#x548C;RenderView.</p>
<h1 id>&#x7EC4;&#x4EF6;&#x548C;&#x63A5;&#x53E3;</h1>
<p><strong>&#x6E32;&#x67D3;&#x8FDB;&#x7A0B;:</strong></p>
<ul>
<li>RenderProcess&#x5728;&#x6D4F;&#x89C8;&#x5668;&#x4E2D;&#x4F7F;&#x7528;&#x76F8;&#x5E94;&#x7684;RenderProcessHost&#x5904;&#x7406;IPC.&#x6BCF;&#x4E2A;&#x6E32;&#x67D3;&#x8FC7;&#x7A0B;&#x53EA;&#x6709;&#x4E00;&#x4E2A;RenderProcess&#x5BF9;&#x8C61;.&#x8FD9;&#x5C31;&#x662F;&#x6240;&#x6709;&#x6D4F;&#x89C8;&#x5668;&#x2194;&#x6E32;&#x67D3;&#x5668;&#x901A;&#x4FE1;&#x7684;&#x53D1;&#x751F;&#x65B9;&#x5F0F;&#x3002;</li>
<li>RenderView&#x5BF9;&#x8C61;&#x5728;&#x6D4F;&#x89C8;&#x5668;&#x8FDB;&#x7A0B;&#xFF08;&#x901A;&#x8FC7;RenderProcess&#xFF09;&#x548C;&#x6211;&#x4EEC;&#x7684;WebKit&#x5D4C;&#x5165;&#x5C42;&#x4E0E;&#x5176;&#x5BF9;&#x5E94;&#x7684;RenderViewHost&#x8FDB;&#x884C;&#x901A;&#x4FE1;&#x3002; &#x6B64;&#x5BF9;&#x8C61;&#x8868;&#x793A;Tab&#x6216;&#x5F39;&#x51FA;&#x7A97;&#x53E3;&#x4E2D;&#x7684;&#x4E00;&#x4E2A;&#x7F51;&#x9875;&#x5185;&#x5BB9;</li>
</ul>
<p><strong>&#x6D4F;&#x89C8;&#x5668;&#x8FDB;&#x7A0B;</strong></p>
<ul>
<li>Browser&#x5BF9;&#x8C61;&#x4EE3;&#x8868;&#x4E86;&#x9876;&#x5C42;&#x7684;&#x6D4F;&#x89C8;&#x7A97;&#x53E3;.</li>
<li>RenderProcessHost&#x5BF9;&#x8C61;&#x4EE3;&#x8868;&#x4E86;&#x5355;&#x4E2A;&#x6D4F;&#x89C8;&#x5668;&#x7AEF;&#x2194;&#x6E32;&#x67D3;&#x5668;&#x7684;IPC&#x8FDE;&#x63A5;, &#x6BCF;&#x4E2A;&#x6E32;&#x67D3;&#x8FDB;&#x7A0B;&#x5728;&#x6D4F;&#x89C8;&#x5668;&#x8FDB;&#x7A0B;&#x4E2D;&#x90FD;&#x6709;&#x4E00;&#x4E2A;RenderProcessHost&#x5BF9;&#x8C61;.</li>
<li>RenderViewHost&#x5BF9;&#x8C61;&#x5C01;&#x88C5;&#x4E86;&#x4E0E;&#x8FDC;&#x7A0B;RenderView&#x7684;&#x901A;&#x4FE1;,RenderWidgetHost&#x5728;&#x6D4F;&#x89C8;&#x5668;&#x4E2D;&#x5904;&#x7406;RenderWidget&#x7684;&#x8F93;&#x5165;&#x548C;&#x7ED8;&#x5236;.</li>
</ul>
<p>&#x6709;&#x5173;&#x5D4C;&#x5165;&#x5C42;&#x662F;&#x5982;&#x4F55;&#x5DE5;&#x4F5C;&#x7684;&#x66F4;&#x591A;&#x8BE6;&#x7EC6;&#x4FE1;&#x606F;&#xFF0C;&#x8BF7;&#x53C2;&#x9605;<a href="https://www.chromium.org/developers/design-documents/displaying-a-web-page-in-chrome?ref=lichen.in">How Chromium displays web pages</a>&#x3002;</p>
<h1 id>&#x5171;&#x4EAB;&#x6E32;&#x67D3;&#x8FDB;&#x7A0B;</h1>
<p>&#x901A;&#x5E38;,&#x6BCF;&#x4E2A;&#x65B0;&#x7A97;&#x53E3;&#x6216;Tab&#x90FD;&#x4F1A;&#x5728;&#x65B0;&#x8FDB;&#x7A0B;&#x4E2D;&#x6253;&#x5F00;.&#x6D4F;&#x89C8;&#x5668;&#x5C06;&#x751F;&#x6210;&#x4E00;&#x4E2A;&#x65B0;&#x8FDB;&#x7A0B;&#x5E76;&#x521B;&#x5EFA;&#x4E00;&#x4E2A;&#x65B0;&#x7684;RenderView&#x3002;</p>
<p>&#x6709;&#x65F6;&#xFF0C;&#x6211;&#x4EEC;&#x5E0C;&#x671B;&#x5728;&#x80FD;&#x5728;Tab&#x6216;&#x7A97;&#x53E3;&#x4E4B;&#x95F4;&#x5171;&#x4EAB;&#x6E32;&#x67D3;&#x8FDB;&#x7A0B;. Web&#x5E94;&#x7528;&#x7A0B;&#x5E8F;&#x6253;&#x5F00;&#x65B0;&#x7A97;&#x53E3;,&#x671F;&#x671B;&#x4E0E;&#x5176;&#x540C;&#x6B65;&#x901A;&#x4FE1;,&#x4F8B;&#x5982;,&#x4F7F;&#x7528;JavaScript&#x4E2D;&#x7684;window.open. &#x5982;&#x679C;&#x8FDB;&#x7A0B;&#x603B;&#x6570;&#x592A;&#x5927;,&#x6216;&#x8005;&#x7528;&#x6237;&#x5DF2;&#x7ECF;&#x6253;&#x5F00;&#x5230;&#x8BE5;&#x57DF;&#x7684;&#x5BFC;&#x822A;,&#x5728;&#x8FD9;&#x79CD;&#x60C5;&#x51B5;&#x4E0B;&#xFF0C;&#x5F53;&#x6211;&#x4EEC;&#x521B;&#x5EFA;&#x4E00;&#x4E2A;&#x65B0;&#x7A97;&#x53E3;&#x6216;Tab&#x65F6;&#xFF0C;&#x6211;&#x4EEC;&#x9700;&#x8981;&#x91CD;&#x7528;&#x5DF2;&#x7ECF;&#x6253;&#x5F00;&#x7A97;&#x53E3;&#x7684;&#x8FDB;&#x7A0B;. &#x6211;&#x4EEC;&#x8FD8;&#x6709;&#x7B56;&#x7565;&#x4E3A;&#x73B0;&#x6709;&#x8FDB;&#x7A0B;&#x5206;&#x914D;&#x65B0;Tab.<a href="https://www.chromium.org/developers/design-documents/process-models?ref=lichen.in">Process Models</a>&#x4E2D;&#x63CF;&#x8FF0;&#x4E86;&#x8FD9;&#x4E9B;&#x7B56;&#x7565;.</p>
<h1 id>&#x68C0;&#x6D4B;&#x5D29;&#x6E83;&#x548C;&#x6E32;&#x67D3;&#x5668;&#x7684;&#x5F02;&#x5E38;&#x884C;&#x4E3A;</h1>
<p>&#x6BCF;&#x4E2A;&#x4E0E;&#x6D4F;&#x89C8;&#x5668;&#x8FDB;&#x7A0B;&#x7684;IPC&#x8FDE;&#x63A5;&#x90FD;&#x4F1A;&#x76D1;&#x89C6;&#x8FDB;&#x7A0B;&#x53E5;&#x67C4;.&#x5982;&#x679C;&#x8FD9;&#x4E9B;&#x53E5;&#x67C4;&#x53D1;&#x51FA;&#x4FE1;&#x53F7;,&#x5219;&#x6E32;&#x67D3;&#x8FDB;&#x7A0B;&#x5DF2;&#x7ECF;&#x5D29;&#x6E83;,&#x5E76;&#x4E14;&#x4F1A;&#x5411;Tab&#x901A;&#x77E5;&#x5D29;&#x6E83;.&#x73B0;&#x5728;,&#x6211;&#x4EEC;&#x4F1A;&#x663E;&#x793A;&#x4E00;&#x4E2A;&#x201C;sad tab&#x201D;&#x5728;&#x5C4F;&#x5E55;&#x4E0A;,&#x901A;&#x77E5;&#x7528;&#x6237;&#x6E32;&#x67D3;&#x5668;&#x5DF2;&#x7ECF;&#x5D29;&#x6E83;. &#x53EF;&#x4EE5;&#x91CD;&#x65B0;&#x52A0;&#x8F7D;&#x6309;&#x94AE;&#x6216;&#x5F00;&#x59CB;&#x53EF;&#x4EE5;&#x6253;&#x5F00;&#x4E00;&#x4E2A;&#x65B0;&#x7684;&#x5BFC;&#x822A;. &#x53D1;&#x751F;&#x8FD9;&#x79CD;&#x60C5;&#x51B5;&#x65F6;&#xFF0C;&#x6211;&#x4EEC;&#x8981;&#x6CE8;&#x610F;,&#x6D4F;&#x89C8;&#x5668;&#x5E76;&#x6CA1;&#x6709;&#x4EFB;&#x4F55;&#x4E00;&#x4E2A;&#x8FDB;&#x7A0B;&#x5E76;&#x4E14;&#x4E5F;&#x4E0D;&#x4F1A;&#x521B;&#x5EFA;&#x4E00;&#x4E2A;&#x65B0;&#x8FDB;&#x7A0B;.</p>
<h1 id>&#x6C99;&#x7BB1;&#x6E32;&#x67D3;&#x5668;</h1>
<p>&#x8003;&#x8651;&#x5230;&#x6E32;&#x67D3;&#x5668;&#x5728;&#x5355;&#x72EC;&#x7684;&#x8FDB;&#x7A0B;&#x4E2D;&#x8FD0;&#x884C;,&#x6211;&#x4EEC;&#x6709;&#x673A;&#x4F1A;&#x901A;&#x8FC7;&#x6C99;&#x76D2;&#x9650;&#x5236;&#x5176;&#x5BF9;&#x7CFB;&#x7EDF;&#x8D44;&#x6E90;&#x7684;&#x8BBF;&#x95EE;. &#x4F8B;&#x5982;,&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x786E;&#x4FDD;&#x6E32;&#x67D3;&#x5668;&#x53EA;&#x80FD;&#x901A;&#x8FC7;&#x5176;&#x7236;&#x6D4F;&#x89C8;&#x5668;&#x8FDB;&#x7A0B;&#x8BBF;&#x95EE;&#x7F51;&#x7EDC;.&#x540C;&#x6837;,&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x4E3B;&#x673A;&#x64CD;&#x4F5C;&#x7CFB;&#x7EDF;&#x7684;&#x5185;&#x7F6E;&#x6743;&#x9650;&#x6765;&#x9650;&#x5236;&#x5176;&#x5BF9;&#x6587;&#x4EF6;&#x7CFB;&#x7EDF;&#x7684;&#x8BBF;&#x95EE;.</p>
<h1 id>&#x6062;&#x590D;&#x5185;&#x5B58;</h1>
<p>&#x8003;&#x8651;&#x5230;&#x6E32;&#x67D3;&#x5668;&#x5728;&#x5355;&#x72EC;&#x7684;&#x8FDB;&#x7A0B;&#x4E2D;&#x8FD0;&#x884C;,&#x90A3;&#x4E48;&#x5C06;&#x9690;&#x85CF;Tab,&#x8FD9;&#x79CD;&#x8F83;&#x4F4E;&#x4F18;&#x5148;&#x7EA7;&#x7684;&#x64CD;&#x4F5C;&#x53D8;&#x5F97;&#x7B80;&#x5355;&#x660E;&#x4E86;.&#x901A;&#x5E38;,Windows&#x4E0A;&#x6700;&#x5C0F;&#x5316;&#x7684;&#x8FDB;&#x7A0B;&#x4F1A;&#x5C06;&#x5176;&#x5185;&#x5B58;&#x81EA;&#x52A8;&#x653E;&#x5165;&#x201C;&#x53EF;&#x7528;&#x5185;&#x5B58;&#x201D;&#x6C60;&#x4E2D;.&#x5728;&#x5185;&#x5B58;&#x4E0D;&#x8DB3;&#x7684;&#x60C5;&#x51B5;&#x4E0B;,Windows&#x4F1A;&#x5728;&#x5C06;&#x6B64;&#x5185;&#x5B58;&#x8F6C;&#x5230;&#x5230;&#x786C;&#x76D8;&#x4E0A;,&#x800C;&#x4E0D;&#x662F;&#x8F6C;&#x79FB;&#x4F18;&#x5148;&#x7EA7;&#x8F83;&#x9AD8;&#x7684;&#x5185;&#x5B58;,&#x4ECE;&#x800C;&#x6709;&#x52A9;&#x4E8E;&#x4FDD;&#x6301;&#x7528;&#x6237;&#x53EF;&#x89C1;&#x7A0B;&#x5E8F;&#x7684;&#x54CD;&#x5E94;&#x901F;&#x5EA6;.&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x5C06;&#x76F8;&#x540C;&#x7684;&#x539F;&#x5219;&#x5E94;&#x7528;&#x4E8E;&#x9690;&#x85CF;&#x7684;Tab.&#x5F53;&#x6E32;&#x67D3;&#x8FDB;&#x7A0B;&#x6CA1;&#x6709;&#x9876;&#x7EA7;Tab&#x65F6;&#xFF0C;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x91CA;&#x653E;&#x8BE5;&#x8FDB;&#x7A0B;&#x7684;&#x201C;&#x5DE5;&#x4F5C;&#x96C6;&#x201D;,&#x4F5C;&#x4E3A;&#x7ED9;&#x7CFB;&#x7EDF;&#x7684;&#x63D0;&#x793A;&#xFF0C;&#x4EE5;&#x4FBF;&#x5728;&#x5FC5;&#x8981;&#x65F6;&#x9996;&#x5148;&#x5C06;&#x8BE5;&#x5185;&#x5B58;&#x8F6C;&#x79FB;&#x5230;&#x78C1;&#x76D8;&#x3002;&#x56E0;&#x4E3A;&#x6211;&#x4EEC;&#x53D1;&#x73B0;&#x5F53;&#x7528;&#x6237;&#x5728;&#x4E24;&#x4E2A;&#x6807;&#x7B7E;&#x4E4B;&#x95F4;&#x5207;&#x6362;&#x65F6;,&#x51CF;&#x5C0F;&#x5DE5;&#x4F5C;&#x96C6;&#x5927;&#x5C0F;&#x4E5F;&#x4F1A;&#x964D;&#x4F4E;Tab&#x5207;&#x6362;&#x6027;&#x80FD;,&#x6240;&#x6211;&#x4EEC;&#x4F1A;&#x9010;&#x6B65;&#x91CA;&#x653E;&#x8FD9;&#x4E2A;&#x5185;&#x5B58;.&#x8FD9;&#x610F;&#x5473;&#x7740;&#x5982;&#x679C;&#x7528;&#x6237;&#x5207;&#x6362;&#x56DE;&#x6700;&#x8FD1;&#x4F7F;&#x7528;&#x7684;Tab&#x65F6;,&#x8BE5;Tab&#x7684;&#x5185;&#x5B58;&#x6BD4;&#x6700;&#x8FD1;&#x4F7F;&#x7528;&#x7684;Tab&#x66F4;&#x5BB9;&#x6613;&#x88AB;&#x6362;&#x5165;.&#x5F53;&#x6709;&#x8DB3;&#x591F;&#x5185;&#x5B58;&#x6765;&#x8FD0;&#x884C;&#x6240;&#x6709;&#x7A0B;&#x5E8F;&#x65F6;,&#x7528;&#x6237;&#x6839;&#x672C;&#x4E0D;&#x4F1A;&#x6CE8;&#x610F;&#x5230;&#x8FD9;&#x4E2A;&#x8FC7;&#x7A0B;:Windows&#x53EA;&#x4F1A;&#x5728;&#x9700;&#x8981;&#x65F6;&#x624D;&#x4F1A;&#x56DE;&#x6536;&#x8FD9;&#x4E9B;&#x6570;&#x636E;,&#x56E0;&#x6B64;&#x5728;&#x5185;&#x5B58;&#x5145;&#x8DB3;&#x65F6;&#x4E0D;&#x4F1A;&#x6709;&#x6027;&#x80FD;&#x635F;&#x5931;.</p>
<p>&#x8FD9;&#x6709;&#x52A9;&#x4E8E;&#x6211;&#x4EEC;&#x5728;&#x4F4E;&#x5185;&#x5B58;&#x60C5;&#x51B5;&#x4E0B;&#x83B7;&#x5F97;&#x66F4;&#x4F73;&#x7684;&#x5185;&#x5B58;&#x5360;&#x7528;. &#x4E0E;&#x5F88;&#x5C11;&#x4F7F;&#x7528;&#x7684;&#x540E;&#x53F0;Tab&#x76F8;&#x5173;&#x8054;&#x7684;&#x5185;&#x5B58;&#x53EF;&#x4EE5;&#x5B8C;&#x5168;&#x6362;&#x51FA;&#xFF0C;&#x800C;&#x524D;&#x53F0;Tab&#x7684;&#x6570;&#x636E;&#x53EF;&#x4EE5;&#x5B8C;&#x5168;&#x52A0;&#x8F7D;&#x5230;&#x5185;&#x5B58;&#x4E2D;&#x3002; &#x76F8;&#x6BD4;&#x4E4B;&#x4E0B;&#xFF0C;&#x5355;&#x8FDB;&#x7A0B;&#x6D4F;&#x89C8;&#x5668;&#x5C06;&#x6240;&#x6709;&#x9009;&#x9879;&#x5361;&#x7684;&#x6570;&#x636E;&#x968F;&#x673A;&#x5206;&#x5E03;&#x5728;&#x5176;&#x5185;&#x5B58;&#x4E2D;&#xFF0C;&#x5E76;&#x4E14;&#x4E0D;&#x53EF;&#x80FD;&#x5982;&#x6B64;&#x5E72;&#x51C0;&#x5730;&#x5206;&#x79BB;&#x5DF2;&#x4F7F;&#x7528;&#x548C;&#x672A;&#x4F7F;&#x7528;&#x7684;&#x6570;&#x636E;&#xFF0C;&#x4ECE;&#x800C;&#x6D6A;&#x8D39;&#x5185;&#x5B58;&#x548C;&#x6027;&#x80FD;&#x3002;</p>
<h1 id>&#x63D2;&#x4EF6;&#x548C;&#x6269;&#x5C55;&#x7A0B;&#x5E8F;</h1>
<p>Firefox&#x98CE;&#x683C;&#x7684;NPAPI&#x63D2;&#x4EF6;&#x5728;&#x81EA;&#x5DF1;&#x7684;&#x8FDB;&#x7A0B;&#x4E2D;&#x8FD0;&#x884C;&#xFF0C;&#x4E0E;&#x6E32;&#x67D3;&#x5668;&#x5206;&#x5F00;&#x3002; &#x8FD9;&#x5728;<a href="https://www.chromium.org/developers/design-documents/plugin-architecture?ref=lichen.in">Plugin Architecture</a>&#x4E2D;&#x6709;&#x8BE6;&#x7EC6;&#x63CF;&#x8FF0;&#x3002;<br>
<a href="https://www.chromium.org/developers/design-documents/site-isolation?ref=lichen.in">Site Isolation</a>&#x9879;&#x76EE;&#x65E8;&#x5728;&#x63D0;&#x4F9B;&#x6E32;&#x67D3;&#x5668;&#x4E4B;&#x95F4;&#x7684;&#x66F4;&#x591A;&#x9694;&#x79BB;&#xFF0C;&#x6B64;&#x9879;&#x76EE;&#x7684;&#x65E9;&#x671F;&#x6210;&#x679C;&#x5305;&#x62EC;&#x5728;&#x9694;&#x79BB;&#x8FDB;&#x7A0B;&#x4E2D;&#x8FD0;&#x884C;Chrome HTML / JavaScript&#x5185;&#x5BB9;&#x7684;&#x6269;&#x5C55;&#x7A0B;&#x5E8F;&#x3002;</p>
<!--kg-card-end: markdown-->]]></content:encoded></item><item><title><![CDATA[Could not read input channel file descriptors from parcel引发的句柄泄露问题]]></title><description><![CDATA[<!--kg-card-begin: markdown--><p>&#x6700;&#x8FD1;&#x5F00;&#x53D1;&#x529F;&#x80FD;&#x7684;&#x65F6;&#x5019;monkey&#x603B;&#x662F;&#x80FD;&#x8DD1;&#x51FA;&#x4E00;&#x4E2A;bug,<br>
<code>java.lang.RuntimeException: Could not read input channel file descriptors from parcel.</code><br>
&#x767E;&#x601D;&#x4E0D;&#x5F97;&#x5176;&#x89E3;,&#x8BA4;&#x4E3A;&#x662F;&#x7CFB;&#x7EDF;&#x4E0A;&#x9762;&#x7684;bug,&#x5B9E;&#x65F6;&#x8BC1;&#x660E;&#x81EA;</p>]]></description><link>http://www.lichen.in/could-not-read-input-channel-file-descriptors-from-parcel/</link><guid isPermaLink="false">5b7d0232cc63df2ef9d26d4e</guid><dc:creator><![CDATA[lichen]]></dc:creator><pubDate>Fri, 25 Aug 2023 20:36:57 GMT</pubDate><content:encoded><![CDATA[<!--kg-card-begin: markdown--><p>&#x6700;&#x8FD1;&#x5F00;&#x53D1;&#x529F;&#x80FD;&#x7684;&#x65F6;&#x5019;monkey&#x603B;&#x662F;&#x80FD;&#x8DD1;&#x51FA;&#x4E00;&#x4E2A;bug,<br>
<code>java.lang.RuntimeException: Could not read input channel file descriptors from parcel.</code><br>
&#x767E;&#x601D;&#x4E0D;&#x5F97;&#x5176;&#x89E3;,&#x8BA4;&#x4E3A;&#x662F;&#x7CFB;&#x7EDF;&#x4E0A;&#x9762;&#x7684;bug,&#x5B9E;&#x65F6;&#x8BC1;&#x660E;&#x81EA;&#x5DF1;&#x8FD8;&#x662F;&#x592A;&#x5E74;&#x8F7B;.&#x73B0;&#x5728;&#x5F00;&#x59CB;&#x5206;&#x6790;&#x4E00;&#x4E0B;&#x8FD9;&#x4E2A;bug&#x4EA7;&#x751F;&#x7684;&#x539F;&#x56E0;.</p>
<h4 id>&#x4E00;.&#x4E3A;&#x4EC0;&#x4E48;&#x4F1A;&#x4EA7;&#x751F;&#x53E5;&#x67C4;&#x6CC4;&#x9732;?</h4>
<p>&#x4F17;&#x6240;&#x5468;&#x77E5;Android&#x662F;linux&#x5185;&#x6838;,&#x4E5F;&#x5C31;&#x662F;&#x53EF;&#x4EE5;&#x7406;&#x89E3;linux&#x4E0B;,&#x4E00;&#x5207;&#x8D44;&#x6E90;&#x90FD;&#x662F;&#x53E5;&#x67C4;,&#x6BCF;&#x4E2A;&#x8FDB;&#x7A0B;&#x90FD;&#x6709;&#x81EA;&#x5DF1;&#x7684;&#x53E5;&#x67C4;&#x4E0A;&#x9650;,&#x800C;&#x8D85;&#x8FC7;&#x4E86;&#x8FD9;&#x4E2A;&#x53E5;&#x67C4;&#x4E0A;&#x7EBF;,&#x5C31;&#x4F1A;&#x53D1;&#x751F;&#x5F02;&#x5E38;.&#x4E00;&#x822C;android&#x7684;App&#x90FD;&#x662F;&#x5728;&#x5355;&#x4E2A;&#x8FDB;&#x7A0B;&#x4E0B;&#x8FD0;&#x884C;&#x7684;,FD&#x7684;&#x53E5;&#x67C4;&#x4E0A;&#x9650;&#x662F;1024,&#x8FD9;&#x4E2A;&#x5728;&#x540E;&#x9762;&#x7684;&#x4F1A;&#x8BF4;&#x660E;.&#x4E00;&#x5207;&#x7684;&#x91CD;&#x70B9;&#x90FD;&#x5728;**proc(Processes,&#x865A;&#x62DF;&#x7684;&#x76EE;&#x5F55;&#xFF0C;&#x662F;&#x7CFB;&#x7EDF;&#x5185;&#x5B58;&#x7684;&#x6620;&#x5C04;&#x3002;&#x53EF;&#x76F4;&#x63A5;&#x8BBF;&#x95EE;&#x8FD9;&#x4E2A;&#x76EE;&#x5F55;&#x6765;&#x83B7;&#x53D6;&#x7CFB;&#x7EDF;&#x4FE1;&#x606F;&#x3002; )**&#x8FD9;&#x4E2A;&#x6587;&#x4EF6;&#x5939;&#x4E0B;&#x7684;&#x5185;&#x5BB9;.<br>
&#x8FD9;&#x91CC;&#x6709;&#x53C2;&#x8003;<a href="https://www.centos.org/docs/5/html/5.1/Deployment_Guide/ch-proc.html?ref=lichen.in">The proc File System</a>.</p>
<blockquote>
<p>The Linux kernel has two primary functions: to control access to physical devices on the computer and to schedule when and how processes interact with these devices. The /proc/ directory &#x2014; also called the proc file system &#x2014; contains a hierarchy of special files which represent the current state of the kernel &#x2014; allowing applications and users to peer into the kernel&apos;s view of the system.</p>
</blockquote>
<blockquote>
<p>Within the /proc/ directory, one can find a wealth of information detailing the system hardware and any processes currently running. In addition, some of the files within the /proc/ directory tree can be manipulated by users and applications to communicate configuration changes to the kernel.</p>
</blockquote>
<p>Linux&#x7CFB;&#x7EDF;&#x4E0A;&#x7684;/proc&#x76EE;&#x5F55;&#x662F;&#x4E00;&#x79CD;&#x6587;&#x4EF6;&#x7CFB;&#x7EDF;&#xFF0C;&#x5373;proc&#x6587;&#x4EF6;&#x7CFB;&#x7EDF;&#x3002;&#x4E0E;&#x5176;&#x5B83;&#x5E38;&#x89C1;&#x7684;&#x6587;&#x4EF6;&#x7CFB;&#x7EDF;&#x4E0D;&#x540C;&#x7684;&#x662F;&#xFF0C;/proc&#x662F;&#x4E00;&#x79CD;&#x4F2A;&#x6587;&#x4EF6;&#x7CFB;&#x7EDF;&#xFF08;&#x4E5F;&#x5373;&#x865A;&#x62DF;&#x6587;&#x4EF6;&#x7CFB;&#x7EDF;&#xFF09;&#xFF0C;&#x5B58;&#x50A8;&#x7684;&#x662F;&#x5F53;&#x524D;&#x5185;&#x6838;&#x8FD0;&#x884C;&#x72B6;&#x6001;&#x7684;&#x4E00;&#x7CFB;&#x5217;&#x7279;&#x6B8A;&#x6587;&#x4EF6;&#xFF0C;&#x7528;&#x6237;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;&#x8FD9;&#x4E9B;&#x6587;&#x4EF6;&#x67E5;&#x770B;&#x6709;&#x5173;&#x7CFB;&#x7EDF;&#x786C;&#x4EF6;&#x53CA;&#x5F53;&#x524D;&#x6B63;&#x5728;&#x8FD0;&#x884C;&#x8FDB;&#x7A0B;&#x7684;&#x4FE1;&#x606F;&#xFF0C;&#x751A;&#x81F3;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;&#x66F4;&#x6539;&#x5176;&#x4E2D;&#x67D0;&#x4E9B;&#x6587;&#x4EF6;&#x6765;&#x6539;&#x53D8;&#x5185;&#x6838;&#x7684;&#x8FD0;&#x884C;&#x72B6;&#x6001;&#x3002;</p>
<h4 id>&#x4E8C;.&#x67E5;&#x770B;&#x8FDB;&#x7A0B;&#x7684;&#x53E5;&#x67C4;&#x4FE1;&#x606F;</h4>
<p>&#x6211;&#x4EEC;&#x901A;&#x8FC7;proc&#x8FD9;&#x4E2A;&#x865A;&#x62DF;&#x6587;&#x4EF6;&#x7CFB;&#x7EDF;,&#x53EF;&#x4EE5;&#x83B7;&#x53D6;&#x5230;&#x5F53;&#x524D;App&#x7684;&#x8FDB;&#x7A0B;,&#x7136;&#x540E;&#x67E5;&#x770B;&#x5177;&#x4F53;&#x7684;&#x8FDB;&#x7A0B;&#x4FE1;&#x606F;,&#x5F53;&#x524D;App&#x662F;&#x5426;&#x5B58;&#x5728;&#x53E5;&#x67C4;&#x6CC4;&#x9732;&#x7684;&#x95EE;&#x9898;.&#x5177;&#x4F53;&#x65B9;&#x6CD5;&#x5982;&#x4E0B;.</p>
<pre><code>
    public class MainActivity extends Activity {
	    private PageView mPageView;
	    private Button mButton;

	    @Override
	    protected void onCreate(Bundle savedInstanceState) {
		 super.onCreate(savedInstanceState);
		 setContentView(R.layout.activity_main);
		 exeCommand(&quot;ps&quot;);

	    }

	    private void exeCommand(String command){
		   Runtime runtime = Runtime.getRuntime();
		   try {
			   Process proc = runtime.exec(command);
			   BufferedReader in = new BufferedReader(new InputStreamReader(proc.getInputStream()));
			   String line;
			   while ((line = in.readLine()) != null) {
				   System.out.println(line);
			   }
		   } catch (IOException e) {
			   e.printStackTrace();
		   }
	   }
    }
</code></pre>
<p>&#x8FD9;&#x6837;&#x6211;&#x4EEC;&#x770B;&#x5230;&#x5728;Android Studio&#x7684;logcat&#x4E2D;&#x6253;&#x5370;&#x51FA;&#x4E86;&#x5F53;&#x524D;&#x6240;&#x6709;&#x7684;&#x8FDB;&#x7A0B;&#x53F7;.<br>
<img src="http://www.lichen.in/content/images/2017/08/----1.png" alt="process_snapshot" loading="lazy"><br>
&#x7136;&#x540E;&#x6211;&#x4EEC;&#x7EE7;&#x7EED;&#x4FEE;&#x6539;&#x6211;&#x4EEC;&#x7684;&#x4EE3;&#x7801;.</p>
<pre><code>exeCommand(&quot;ps | grep com.behanga&quot;);
</code></pre>
<p>com.behanga&#x662F;&#x6211;&#x6D4B;&#x8BD5;App&#x7684;&#x540D;&#x5B57;.<br>
<img src="http://www.lichen.in/content/images/2017/08/----2.png" alt="final_proceess_snapshot" loading="lazy"></p>
<p>&#x8FD9;&#x662F;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x770B;&#x5230;&#x8BE5;App&#x7684;&#x8FDB;&#x7A0B;&#x53F7;&#x662F;16023,&#x4E5F;&#x5C31;&#x662F;&#x8BF4;&#x5BF9;&#x5E94;&#x5728;proc&#x4E2D;&#x5BF9;&#x5E94;&#x7684;&#x6587;&#x4EF6;&#x5939;&#x4E3A;/proc/16023/,&#x5728;&#x8FD9;&#x4E2A;&#x6587;&#x4EF6;&#x5939;&#x4E0B;&#x6211;&#x4EEC;&#x770B;&#x5230;&#x5F53;&#x524D;App&#x7684;&#x4FE1;&#x606F;,&#x597D;&#x6211;&#x4EEC;&#x7EE7;&#x7EED;&#x5F80;&#x4E0B;&#x67E5;&#x770B;.<br>
&#x8FD9;&#x65F6;&#x6211;&#x4EEC;&#x6253;&#x5F00;terminal,&#x8F93;&#x5165;</p>
<pre><code>adb shell
</code></pre>
<p>&#x8FDB;&#x5165;adb shell,&#x7136;&#x540E;&#x8F93;&#x5165;</p>
<pre><code>cd /proc/16023 &amp;&amp; ls -al
</code></pre>
<p>&#x73B0;&#x5728;&#x5C55;&#x793A;&#x5728;&#x6211;&#x4EEC;&#x9762;&#x524D;&#x7684;&#x5C31;&#x662F;&#x5F53;&#x524D;&#x8FDB;&#x7A0B;&#x4E0B;&#x4FE1;&#x606F;.<br>
<img src="http://www.lichen.in/content/images/2017/08/----3.png" alt="process_info" loading="lazy"><br>
&#x6211;&#x4EEC;&#x73B0;&#x5728;&#x53EF;&#x4EE5;&#x67E5;&#x770B;&#x4E00;&#x4E0B;&#x5F53;&#x524D;&#x8FDB;&#x7A0B;&#x4E00;&#x4E9B;&#x9650;&#x5236;.</p>
<pre><code>cat limits
</code></pre>
<p><img src="http://www.lichen.in/content/images/2017/08/----4.png" alt="process_info_limits" loading="lazy"></p>
<p>&#x8FD9;&#x91CC;&#x6211;&#x4EEC;&#x770B;&#x5230;Max open fils&#x7684;&#x9650;&#x5236;&#x4E3A;1024,&#x786C;&#x4EF6;&#x9650;&#x5236;&#x4E3A;4096,&#x4E5F;&#x5C31;&#x662F;&#x8BF4;&#x6211;&#x4EEC;&#x5F53;&#x524D;&#x6253;&#x5F00;&#x6587;&#x4EF6;&#x53E5;&#x67C4;&#x7684;&#x6700;&#x5927;&#x6570;&#x4E3A;1024.</p>
<p>&#x8FD9;&#x65F6;&#x6211;&#x4EEC;&#x7EE7;&#x7EED;&#x5F80;&#x4E0B;&#x770B;,&#x56E0;&#x4E3A;&#x662F;&#x8981;&#x5206;&#x6790;file descriptors&#x7684;&#x95EE;&#x9898;,&#x90A3;&#x4E48;&#x81EA;&#x7136;&#x8981;&#x8FDB;&#x5165;fd&#x76EE;&#x5F55;&#x4E0B;&#x4E00;&#x770B;&#x7A76;&#x7ADF;.</p>
<pre><code>cd fd &amp;&amp; ls -al
</code></pre>
<p><img src="http://www.lichen.in/content/images/2017/08/----5.png" alt="fd_info" loading="lazy"></p>
<p>&#x5F53;&#x524D;&#x5C55;&#x793A;&#x4E86;&#x6240;&#x5728;&#x8FDB;&#x7A0B;&#x4E0B;&#x6240;&#x6709;&#x5DF2;&#x7ECF;&#x88AB;&#x6253;&#x5F00;&#x7684;&#x6587;&#x4EF6;&#x53E5;&#x67C4;.&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x5728;&#x5F53;&#x524D;&#x6587;&#x4EF6;&#x5939;&#x4E0B;&#x7EDF;&#x8BA1;&#x6240;&#x6709;&#x7684;&#x53E5;&#x67C4;&#x603B;&#x6570;.</p>
<pre><code>ls | wc -l
</code></pre>
<p>&#x8FD9;&#x65F6;&#x6253;&#x5370;&#x51FA;&#x6240;&#x6709;&#x7684;&#x53E5;&#x67C4;&#x603B;&#x6570;&#x4E3A;64.&#x8FD9;&#x65F6;&#x6211;&#x4EEC;&#x5DF2;&#x7ECF;&#x5B8C;&#x6210;&#x5BF9;&#x5F53;&#x524D;&#x8FDB;&#x7A0B;&#x7684;&#x4E00;&#x4E9B;&#x53E5;&#x67C4;&#x4FE1;&#x606F;&#x67E5;&#x770B;.</p>
<h4 id>&#x4E09;.&#x6A21;&#x62DF;&#x53E5;&#x67C4;&#x6CC4;&#x9732;&#x60C5;&#x51B5;</h4>
<p>&#x5982;&#x679C;&#x6211;&#x4EEC;&#x8981;&#x6A21;&#x62DF;&#x53E5;&#x67C4;&#x6CC4;&#x6F0F;&#x7684;&#x60C5;&#x51B5;,&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x5728;App&#x4E2D;&#x542F;&#x52A8;&#x4E00;&#x4E2A;HandlerThread,&#x6BCF;&#x6B21;&#x5728;onCreate&#x7684;&#x65F6;&#x5019;HandlerThread.start(),&#x4F46;&#x662F;&#x5728;onDestory()&#x65F6;,&#x5E76;&#x4E0D;&#x8C03;&#x7528;HandlerThread.quit()&#x65B9;&#x6CD5;.&#x91CD;&#x590D;&#x8FDB;&#x5165;.&#x7136;&#x540E;&#x5728;terminal&#x4E2D;&#x7EDF;&#x8BA1;FD&#x7684;&#x603B;&#x6570;,&#x67E5;&#x770B;&#x662F;&#x5426;&#x6709;&#x53D8;&#x5316;,&#x5982;&#x679C;FD&#x7684;&#x603B;&#x6570;&#x4E00;&#x76F4;&#x5728;&#x589E;&#x52A0;,&#x5C31;&#x53EF;&#x4EE5;&#x786E;&#x8BA4;&#x4F60;&#x5F53;&#x524D;App&#x4E2D;&#x5DF2;&#x7ECF;&#x51FA;&#x73B0;&#x4E86;&#x53E5;&#x67C4;&#x6CC4;&#x9732;&#x7684;&#x60C5;&#x51B5;.</p>
<h4 id>&#x56DB;.&#x5982;&#x4F55;&#x907F;&#x514D;&#x53E5;&#x67C4;&#x6CC4;&#x9732;&#x7684;&#x53D1;&#x751F;</h4>
<p>&#x63D0;&#x9AD8;&#x5BF9;&#x7F16;&#x7801;&#x610F;&#x8BC6;,&#x53E6;&#x5916;&#x5C31;&#x662F;monkey&#x7684;&#x6D4B;&#x8BD5;,&#x5F88;&#x591A;&#x65F6;&#x5019;&#x4F1A;&#x53D1;&#x73B0;&#x4E00;&#x4E9B;&#x9ED1;&#x76D2;&#x6D4B;&#x8BD5;&#x65E0;&#x6CD5;&#x53D1;&#x73B0;&#x7684;&#x95EE;&#x9898;.</p>
<!--kg-card-end: markdown-->]]></content:encoded></item><item><title><![CDATA[Vue tips]]></title><description><![CDATA[<ol><li>Vue&#x7684;&#x751F;&#x547D;&#x5468;&#x671F;&#x4E2D;, <code>$rounter</code> &#x53EF;&#x80FD;&#x5728; <code>created</code> &#x548C; <code>mounted</code> &#x9636;&#x6BB5;&#x5E76;&#x6CA1;&#x6709;&#x521D;&#x59CB;&#x5316;&#x597D;,&#x8FD9;&#x65F6;&#x4F7F;&#x7528; <code>push</code> &#x6216;&#x8005; <code>replace</code> &#x662F;&#x65E0;&#x6548;&#x7684;,&#x8FD9;&#x65F6;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x8FD9;&#x4E2A;&#x65B9;&#x6CD5;&#x6765;&#x89E3;&#x51B3;</li></ol>]]></description><link>http://www.lichen.in/vue-tips/</link><guid isPermaLink="false">622029e53fab384365b11bb3</guid><dc:creator><![CDATA[lichen]]></dc:creator><pubDate>Fri, 25 Aug 2023 20:32:34 GMT</pubDate><content:encoded><![CDATA[<ol><li>Vue&#x7684;&#x751F;&#x547D;&#x5468;&#x671F;&#x4E2D;, <code>$rounter</code> &#x53EF;&#x80FD;&#x5728; <code>created</code> &#x548C; <code>mounted</code> &#x9636;&#x6BB5;&#x5E76;&#x6CA1;&#x6709;&#x521D;&#x59CB;&#x5316;&#x597D;,&#x8FD9;&#x65F6;&#x4F7F;&#x7528; <code>push</code> &#x6216;&#x8005; <code>replace</code> &#x662F;&#x65E0;&#x6548;&#x7684;,&#x8FD9;&#x65F6;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x8FD9;&#x4E2A;&#x65B9;&#x6CD5;&#x6765;&#x89E3;&#x51B3;&#x8FD9;&#x4E2A;&#x95EE;&#x9898;:</li></ol><pre><code class="language-javascript">this.queryParams = this.$route.query
this.$router.onReady(() =&gt; {
   this.$router.push({ query })
})</code></pre>]]></content:encoded></item></channel></rss>