How to limit memory of a OS X program? ulimit -v neither -m are working

You can’t. Apple can (using the ledger() system call, which is private), but you can’t. I’m not entirely sure whether launchd’s options work or not – certainly if it was still using the code visible in the last open source version (from 10.9.5), it wouldn’t, because it calls setrlimit(), but it’s been substantially rewritten since … Read more

How to design a C++ API for binary compatible extensibility

Several months ago I wrote an article called “Binary Compatibility of Shared Libraries Implemented in C++ on GNU/Linux Systems” [pdf]. While concepts are similar on Windows system, I’m sure they’re not exactly the same. But having read the article you can get a notion on what’s going on at C++ binary level that has anything … Read more

Print address of virtual member function

Currently there is no standard way of doing this in C++ although the information must be available somewhere. Otherwise, how could the program call the function? However, GCC provides an extension that allows us to retrieve the address of a virtual function: void (A::*mfp)() = &A::func; printf(“address: %p”, (void*)(b->*mfp)); …assuming the member function has the … Read more

Alternative to c++ static virtual methods

You can make Base be a class template that takes its function pointers from its template argument: extern “C” { struct CStruct { void (*funA)(int, char const*); int (*funB)(void); }; } template <typename T> class Base { public: CStruct myStruct; void FillPointers() { myStruct.funA = &T::myFunA; myStruct.funB = &T::myFunB; } Base() { FillPointers(); } }; … Read more

How to do virtual file processing?

You might want to consider using a tempfile.SpooledTemporaryFile which gives you the best of both worlds in the sense that it will create a temporary memory-based virtual file initially but will automatically switch to a physical disk-based file if the data held in memory exceeds a specified size. Another nice feature is that (when using … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)