> HashMap serializes 2 'metadata' ints (table.length, size) and then the > key/value pairs. HashSet serializes 3 'metadata fields' (capacity, > loadFactor, size).
*And* the class names and serialUIDs (8 bytes each!) and other relevant stuff for each Object which makes it possible for JDK to figure out which class to instantiate when deserializing. I suspect that this really takes the most space. > Given that the JDK's implementation seems to be pretty efficient, I'm > not entirely sure that we could do much for SimplePrincipalsCollection > to meet the general case of working in all applications. We also > haven't had any other reports related to this yet, so I think its > really because of the Amazon ELB (i.e. browsers can handle cookies of > the default size no problem). I didn't have that problem until Friday night either, so I suspect Amazon changed something. Unfortunately they've been fairly unresponsive to my email bombardment. > But if you'd like to help out to try to make it more efficient, we'd > love the help! I'd be curious if you could find something - it sounds > like you might already have a test harness up for testing, at which > point it'd be a simple test to change SimplePrincipalCollection's > readObject/writeObject and see what happens. If you try this, please > let us know! My solution works really well only for myself, since I know exactly the principals I'm storing and from which Realm they came. So it's not a generic solution. > But if you ever change your app in the future to support more than one > realm or principal, this might cause you (or someone else) quite a > headache if it isn't documented extremely well ;) Possibly :-). However, I do feel that it's a good enough tradeoff for my own app. (I actually throw an explanatory Exception when the serializer is asked to serialize something it does not know how to serialize - it's pretty much hardcoded to my own Principals.) /Janne
