@@ -434,13 +434,35 @@ cfg_if::cfg_if! {
434
434
}
435
435
}
436
436
437
+ /// Attempt to reclaim that cached memory used to symbolicate addresses.
438
+ ///
439
+ /// This method will attempt to release any global data structures that have
440
+ /// otherwise been cached globally or in the thread which typically represent
441
+ /// parsed DWARF information or similar.
442
+ ///
443
+ /// # Caveats
444
+ ///
445
+ /// While this function is always available it doesn't actually do anything on
446
+ /// most implementations. Libraries like dbghelp or libbacktrace do not provide
447
+ /// facilities to deallocate state and manage the allocated memory. For now the
448
+ /// `gimli-symbolize` feature of this crate is the only feature where this
449
+ /// function has any effect.
450
+ #[ cfg( feature = "std" ) ]
451
+ pub fn clear_symbol_cache ( ) {
452
+ let _guard = crate :: lock:: lock ( ) ;
453
+ unsafe {
454
+ clear_symbol_cache_imp ( ) ;
455
+ }
456
+ }
457
+
437
458
mod dladdr;
438
459
439
460
cfg_if:: cfg_if! {
440
461
if #[ cfg( all( windows, target_env = "msvc" , feature = "dbghelp" ) ) ] {
441
462
mod dbghelp;
442
463
use self :: dbghelp:: resolve as resolve_imp;
443
464
use self :: dbghelp:: Symbol as SymbolImp ;
465
+ unsafe fn clear_symbol_cache_imp( ) { }
444
466
} else if #[ cfg( all(
445
467
feature = "std" ,
446
468
feature = "gimli-symbolize" ,
@@ -453,6 +475,7 @@ cfg_if::cfg_if! {
453
475
mod gimli;
454
476
use self :: gimli:: resolve as resolve_imp;
455
477
use self :: gimli:: Symbol as SymbolImp ;
478
+ use self :: gimli:: clear_symbol_cache as clear_symbol_cache_imp;
456
479
// Note that we only enable coresymbolication on iOS when debug assertions
457
480
// are enabled because it's helpful in debug mode but it looks like apps get
458
481
// rejected from the app store if they use this API, see #92 for more info
@@ -462,22 +485,26 @@ cfg_if::cfg_if! {
462
485
mod coresymbolication;
463
486
use self :: coresymbolication:: resolve as resolve_imp;
464
487
use self :: coresymbolication:: Symbol as SymbolImp ;
488
+ unsafe fn clear_symbol_cache_imp( ) { }
465
489
} else if #[ cfg( all( feature = "libbacktrace" ,
466
490
any( unix, all( windows, not( target_vendor = "uwp" ) , target_env = "gnu" ) ) ,
467
491
not( target_os = "fuchsia" ) ,
468
492
not( target_os = "emscripten" ) ) ) ] {
469
493
mod libbacktrace;
470
494
use self :: libbacktrace:: resolve as resolve_imp;
471
495
use self :: libbacktrace:: Symbol as SymbolImp ;
496
+ unsafe fn clear_symbol_cache_imp( ) { }
472
497
} else if #[ cfg( all( unix,
473
498
not( target_os = "emscripten" ) ,
474
499
feature = "dladdr" ) ) ] {
475
500
mod dladdr_resolve;
476
501
use self :: dladdr_resolve:: resolve as resolve_imp;
477
502
use self :: dladdr_resolve:: Symbol as SymbolImp ;
503
+ unsafe fn clear_symbol_cache_imp( ) { }
478
504
} else {
479
505
mod noop;
480
506
use self :: noop:: resolve as resolve_imp;
481
507
use self :: noop:: Symbol as SymbolImp ;
508
+ unsafe fn clear_symbol_cache_imp( ) { }
482
509
}
483
510
}
0 commit comments