al8n / stretto

Stretto is a Rust implementation for Dgraph's ristretto (https://github.com/dgraph-io/ristretto). A high performance memory-bound Rust cache.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Stacks on close() while code compiled as cdylib

Numenorean opened this issue · comments

It's great that with your lib i can do such things

lazy_static! {
    static ref CACHE: Cache<String, TcpStream> = {
        let cache = Cache::new(12000, 1e6 as i64).unwrap();
        cache
    };
}

But there is 2 issues while compiling code as cdylib:

  1. Without cache.close() in DLL_PROCESS_DETACH (yeah, my lib is for windows), it just throws some kind of error, which rust detects while I loading this dll - STATUS_ACCESS_VIOLATION. In another programs this issues cause whole program crash
  2. I find out to prevent that issue i need to call cache.close() in order to clear some memory, stop additional threads, but now it just stacks on closing and do nothing until I kill process
    I really need your help, because i literally can't find another in-memory cache which can be defined as global value with lazy_static

Hi, there is a method wait which can help you wait for all of the items in the write buffer to be written in the cache (If you have not tried this method). Have you tried to compile the related code on linux? I need to fix out whether it is a bug of Stretto. Or, could you give a piece of example code to help me reproduce the crash situation?