@@ -31,12 +31,13 @@ use std::sync::Arc;
3131use std:: time:: Duration ;
3232use tonic:: transport:: Server ;
3333
34+ use crate :: cli:: { Cli , Commands } ;
3435use actix_web:: { middleware, HttpServer } ;
3536use clap:: Parser ;
3637use env_logger:: TimestampPrecision ;
3738use env_logger_timezone_fmt:: { TimeZoneFormat , TimeZoneFormatEnv } ;
38- //use mimalloc::MiMalloc;
39- use crate :: cli :: { Cli , Commands } ;
39+ # [ cfg ( feature = " mimalloc" ) ]
40+ use mimalloc :: MiMalloc ;
4041use rnacos:: common:: appdata:: AppShareData ;
4142use rnacos:: openapi:: middle:: auth_middle:: ApiCheckAuth ;
4243use rnacos:: raft:: NacosRaft ;
@@ -45,8 +46,9 @@ use rnacos::transfer::mysql_to_data::mysql_to_data;
4546use rnacos:: transfer:: openapi_to_data:: openapi_to_data;
4647use rnacos:: transfer:: sqlite_to_data:: sqlite_to_data;
4748use rnacos:: web_config:: { app_config, console_config} ;
48- //#[global_allocator]
49- //static GLOBAL: MiMalloc = MiMalloc;
49+ #[ cfg( feature = "mimalloc" ) ]
50+ #[ global_allocator]
51+ static GLOBAL : MiMalloc = MiMalloc ;
5052
5153#[ actix_web:: main]
5254async fn main ( ) -> Result < ( ) , Box < dyn Error > > {
@@ -68,6 +70,14 @@ async fn main() -> Result<(), Box<dyn Error>> {
6870 // 这里不使用log:info避免日志等级高于info时不打印
6971 println ! ( "version:{}, RUST_LOG:{}" , get_app_version( ) , & rust_log) ;
7072 println ! ( "data dir:{}" , sys_config. local_db_dir) ;
73+
74+ // 输出内存分配器信息
75+ let allocator_name = if cfg ! ( feature = "mimalloc" ) {
76+ "mimalloc"
77+ } else {
78+ "system default"
79+ } ;
80+ println ! ( "allocator: {}" , allocator_name) ;
7181 let factory_data = config_factory ( sys_config. clone ( ) ) . await ?;
7282 let app_data = build_share_data ( factory_data. clone ( ) ) ?;
7383 let http_addr = sys_config. get_http_addr ( ) ;
0 commit comments