Skip to content

Call the libjuice library, call the library in cpp, the memory occupies 4M, call the library in pure C, the memory occupies 2.5M,Why? #187

@LiuAriel

Description

@LiuAriel

This memory savings in embedded devices is very important, why is the memory gap so large.

Write a cpp file, compile the library with gcc, and then use a C++ class to call libjuice, use When g++ compiles and runs, the memory is 4M. In the same situation, I just implement the C function interface call, and the g++ compile and run memory is only 2.5M. Of course, the C++ class is the simplest structure, and there is no other processing. It seems that as long as any interface of the libjuice library is called by the C++ class, Memory immediately 2M VmRSS
int main() { juice_set_log_level(JUICE_LOG_LEVEL_WARN); test_connectivity(); connectivity* conn = new connectivity(); conn->sendas(); while(true){ sleep(2); } return 0; }
The above codes are saved in .cpp and .c respectively, compiled and run, and it is very clear to view vmRSS.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions