Non destructive data queue utility
2 posts in topic
Flat View  Flat View

Posted By:   Pete_Inman
Posted On:   Friday, February 22, 2002 06:37 AM

I'm trying to write a utility program to display the contents of a data queue in a JTextPane but I don't want to destroy the contents of the queue.

there is a peek() method on the dataqueue object, but this only looks at the first entry on the queue

does anyone know a way around this?

JVM question

Posted By:   blanka_li  
Posted On:   Monday, February 25, 2002 04:26 AM


Please tell me what the difference between "System.gc()" and "Runtime.getRuntime().gc()".
JDK API document says that "System.gc() call Runtime.getRuntime().gc()". So there is no difference. But the test result of as following(windows2000):
7 bytes used per object on average
8 bytes used per object on average

who can tell me why?

public class Memory {

private final static int _SIZE = 500;

public static void main( String [] args ) throws Exception {

Object[] array = new Object[_SIZE];

long start = Runtime.getRuntime().freeMemory();

for (int i = 0; i < _SIZE; i++) {
array[i] = new Object();

long end = Runtime.getRuntime().freeMemory();

long difference = ( start - end ) / _SIZE;

System.out.println( difference + " bytes used per object on average" );




Posted By:   blanka_li  
Posted On:   Monday, February 25, 2002 04:25 AM

please tell me how to put my question on the forum?thanks!
About | Sitemap | Contact