casbin / casbin-cpp

An authorization library that supports access control models like ACL, RBAC, ABAC in C/C++
https://casbin.org
Apache License 2.0
218 stars 61 forks source link

Memory Leak Detection: Casbin #243

Closed fishsclue closed 2 months ago

fishsclue commented 4 months ago

Description

Calling the enforce method in a loop causes the memory usage to go up all the time, how can I fix this?

Your System Info

#include <iostream>
#include <casbin/casbin.h>

using namespace std;
using namespace casbin;

int main() {

    Enforcer enforcer("path/to/model.conf", "path/to/policy.csv");

    string sub = "alice";  
    string obj = "data1";  
    string act = "read";   

    for (int i = 0; i < 10000; ++i) {
        if (enforcer.Enforce(sub, obj, act)) {
            cout << "allow" << endl;
        } else {
            cout << "deny" << endl;
        }
    }

    return 0;
}

Screenshots/Testimonials

casbin-bot commented 4 months ago

@EmperorYP7 @sheny1xuan @cs1137195420