chenyu468 wrote: > Hi, > I am reading some NSS files. In the structure, the "PRArenaPool" type > (for example, certdb/certt.h) are used in many places, but it seems be > unrelated with the NSS. Could you tell me some background of > "PRArenaPool" and why to use it?
It is defined in NSPR's "plds4" library. See http://lxr.mozilla.org/nspr/source/nsprpub/lib/ds/. It allows you to allocate a big chunk of memory and then you get your memory from there. It has two purposes: 1. Performance: it reduces the number of times you call malloc, which is a major point of lock contention in multithreaded applications. It may also reduce heap fragmentation. 2. Convenience: when you are done, you just free the arena, as opposed to freeing the individual memory blocks. Note that NSS enhanced PRArenaPool but in the NSS API does not use that "subclass" type (PORTArenaPool). So you must use the Arena functions in NSS's secport.h rather than the Arena functions in NSPR's plarena.h when you use arenas with NSS. Wan-Teh _______________________________________________ mozilla-crypto mailing list [email protected] http://mail.mozilla.org/listinfo/mozilla-crypto
