Hi I think it would probably need to be a static rather than per-document, because you won’t always have a reference to an owner document when dictionaries are being modified.
class PdfName { static Map< std::string, PdfName> s_nameTable; } That would mean keys are always valid (the name table would only be destroyed when the app exits) One issue is threading – I’m not sure what guarantees PoDoFo gives around threading, but this makes dictionary operations non-thread safe unless locking is added. Current memory layout in 32-bit windows is: class PoDoFo::PdfName size(36): 0 (base class PoDoFo::PdfDataType) 0 {vfptr} (size=4) 4 m_bImmutable (size=1) | <alignment member> (size=3) 8 std::string m_Data (size =24) plus 8 bytes HeapAlloc overhead 8 bytes malloc overhead Total: 36+8+8 =52 bytes per dictionary key If the std::string was changed to a ref counted pointer this would change to something like: class PoDoFo::PdfName size(16): 0 (base class PoDoFo::PdfDataType) 0 {vfptr} (size=4) 4 m_bImmutable (size=1) | <alignment member> (size=3) 8 std::string* m_Data (size =4) plus 8 bytes HeapAlloc overhead 8 bytes malloc overhead Total: 31+8+8 =32 bytes per dictionary key If the dictionary keys are changed to PdfName& or PdfName* then it changes to Total: 4 bytes per dictionary key (Sizeof(PdfName*) = sizeof(void*) = 4 bytes) with no heap overhead Best Regards Mark Mark Rogers - mark.rog...@powermapper.com PowerMapper Software Ltd - www.powermapper.com Registered in Scotland No 362274 Quartermile 2 Edinburgh EH3 9GL ------------------------------------------------------------------------------ Developer Access Program for Intel Xeon Phi Processors Access to Intel Xeon Phi processor-based developer platforms. With one year of Intel Parallel Studio XE. Training and support from Colfax. Order your platform today. http://sdm.link/xeonphi _______________________________________________ Podofo-users mailing list Podofo-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/podofo-users