【问题标题】:Where to put Scudo allocator __scudo_default_options callback?在哪里放置 Scudo 分配器 __scudo_default_options 回调?
【发布时间】:2021-05-05 19:46:38
【问题描述】:

来自 Scudo 页面:

Some parameters of the allocator can be defined on a per-process basis through several ways:

Statically: Define a __scudo_default_options function in the program that returns the options string to be parsed. This function must have the following prototype: extern "C" const char *__scudo_default_options().
Dynamically: Use the environment variable SCUDO_OPTIONS containing the options string to be parsed. Options defined this way override any definition made through __scudo_default_options.

我对 Android 还很陌生,有人可以帮我了解在 cpp 代码中将 __scudo_default_options 之类的函数放在哪里,我有 MainActivity.cpp 和 MidiManager.cpp

【问题讨论】:

    标签: android c++ java-native-interface dynamic-memory-allocation


    【解决方案1】:

    该函数可以位于应用程序中的任何位置,只要它可以被链接器发现。将它放在主编译单元附近可能会更好。 您要确保该符号具有公共可见性。

    您可以在此处参考测试中的示例: https://github.com/llvm/llvm-project/blob/main/compiler-rt/lib/scudo/standalone/tests/scudo_unit_test_main.cpp#L23

    例如。在 MainActivity.cpp 中,达到以下程度:

    extern "C" __attribute__((visibility("default"))) const char *
    __scudo_default_options() {
      return "quarantine_size_kb=256:thread_local_quarantine_size_kb=128:"
             "quarantine_max_chunk_size=512";
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-03-16
      • 2019-07-01
      • 1970-01-01
      • 2017-06-07
      • 2012-04-04
      • 2017-11-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多