java - Best technique for memory allocation - reuse one gloabal memory or allocate many local buffers and let it be garbage collected -


i reading bunch of byte messages file. want read each message buffer, little parsing, , store messages objects field data.

in general, better allocate 1 chunk of memory global reference , reuse each message read or allocate local object different chunk of memory each message(this way can gargage collected since there no global reference)?

also, there reference somewhere has list of java programming practices/design might cover , other desired techniques building java code? have been coding java long time not sure if techniques desirable.

i recommend creational patterns in general. should give platform start with.

five well-known design patterns parts of creational patterns the

  1. abstract factory pattern, provides interface creating related or dependent objects without specifying objects' concrete classes.
  2. builder pattern, separates construction of complex object representation same construction process can create different representations.
  3. factory method pattern, allows class defer instantiation subclasses. =4. prototype pattern, specifies kind of object create using prototypical instance, , creates new objects cloning prototype.
  4. singleton pattern, ensures class has 1 instance, , provides global point of access it.

these creational patterns routinely used in high-performance java applications. there needs lot more detail , testing know pattern improve personal performance.

separately, , going further better managing object life-cycles. there libraries such openhft ( high frequency trading ) let ipc shared memory segment. no, that's not want, , assuming you're not counting microseconds. think illustrates going off gc not far-fetched described.

but if you, i'd experiment suitable creational pattern better manage object lifecycles.


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -