ONJava.com -- The Independent Source for Enterprise Java
oreilly.comSafari Books Online.Conferences.

advertisement

AddThis Social Bookmark Button
Article:
  Real-Time Java: An Introduction
Subject:   heap or stack
Date:   2006-05-13 10:19:34
From:   simon_massey
i took a look at the digital mars language "D" a while back. it has garbage collection but it also allows you to declare an object on the stack if you don't use the new operator. that was a feature that i had forgotten about C and C++. it occurred to me that java could implement stack objects with annotations. that is to say that if you marked a method as being @DefaultStackObjects the compiler could put any new objects into the stack rather than the heap. of course if you did this you would be constrained by the same constraints as NoHeapRealtimeThread - that objects made on the stack are not assignable to normal object references (i.e. a stack object cannot be assigned to a member field of a heap allocated objects passed into the method nor can it be returned by the method which if the calling method is not also running as @DefaultStackObjects). the difference however that the full real time implementation needs a hard core real time operating system. doing stack objects with annotations could be implemented on a normal operating system. it would not give you a real time guarantee but it would give you "scoped memory objects lite" which would keep garbage generation to a minimum (or zero) if you were careful to only allocate onto the heap what you consider to be immortal to your application.

1 to 1 of 1
  1. heap or stack
    2006-05-16 03:23:56  simon_massey [View]

    • heap or stack
      2006-11-15 11:37:38  kss45 [View]

    • heap or stack
      2006-10-26 03:36:29  asldkfjlkasjflj [View]

1 to 1 of 1