Java doesn't have a C-like structure type, so Java objects still have overhead. If you want the absolute minimum number of bytes in memory, you can create Java primitive arrays in Clojure:
(make-array Integer/TYPE 100) Then access them with the "aset..." and "aget" functions. -Stuart Sierra On Mar 9, 1:04 pm, Bradbev <brad.beveri...@gmail.com> wrote: > I'm writing a program that will have millions of small structures in > it. If I were writing in C (or Java I guess), I estimate the object > size to be about 40 bytes. In Clojure, using a struct map I've made a > rough measure & I think that the objects are weighing in at about > 200bytes. > > 1) I know that my measurement methods suck (cons up a big list, look > at the total usage count & try to adjust for list overhead) - is there > a good way that I can measure the size in memory of my structmap? > 2) Is there a good way to optimize the size of these objects in > Clojure? I'd prefer to stay within Clojure, but my current plan to > squeeze the smallest size out is to move to a Java object. > > I also know the types of the struct members, and most of them are > 32bit numbers. Eliminating dynamic types from the struct is probably > important for overall size. > > Any thoughts? > > Cheers, > Brad --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---