• Post Reply Bookmark Topic Watch Topic
  • New Topic

Dynamic memory allocation in JAVA  RSS feed

 
Puja Verma
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If i want to allocate memory while creating thread in my program, how can i do that and later on how can i get to know the memory associated with each thread???
can anyone help me in this
 
Mr. C Lamont Gilbert
Ranch Hand
Posts: 1170
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Memory is managed by the JVM, not by the software. You can not allocate memory in Java. It should not be surprising considering you can not manipulate pointers.

I believe you can use byte arrays as a form of memory allocation if you wish to map your object or resource in bytes.
[ July 19, 2006: Message edited by: Mr. C Lamont Gilbert ]
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16048
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If what you want to do is have one instance of a variable per thread, then have a look at class ThreadLocal (look it up in the API documentation).
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!