Girish K Gupta

Greenhorn
+ Follow
since Mar 14, 2007
Girish likes ...
Eclipse IDE Chrome Java
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
1
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Girish K Gupta

Hi John

Even I had got that error, though I don't remember how many double variables I had used.

In your code example the memory required to store 5028 doubles is around 40k, much more than the specified 1k. It would take only 128 doubles to fill up this memory. I am unable to understand the behaviour.

Thanks
11 years ago
Because for overloading the method arguments MUST be different.
11 years ago
Hi all

Has anyone ever encountered a stackOverFlow error which is not caused by deep recursion?
Theoretically it is possible http://en.wikipedia.org/wiki/Stack_overflow because of big local variables.

I tried reproducing by using a very low stack size (using -Xss8k) and then declaring a large number of local variables but I was unsuccessful.



In this program I am declaring 2000 double variables that would take 2000*8 = 16000 bytes of memory (~16k) which is much more than set 8k but still this program runs successfully.

Any pointers/suggestions? Am I doing anything wrong?

Thanks
11 years ago
Hi Raj

I don't know what types of questions you are looking for but for the one you mentioned in this thread above the Kathy Siera book gives all the required information.

I feel whatever is provided in this book is more than sufficient for an application developer. [Chapter 2, Constructors and Instantiation (Exam Objectives 1.6, 5.3, and 5.4)]
11 years ago
Hi Anayonkar

I tried it but the length of arrays returned getStackTrace() method is always 1024 for my system while value of depth variable is around 12000 in different executions.

Following is the Test application code I am using:



Thanks
11 years ago
Hi Raj

These are standard questions with constructor-chaining concept.
In all constructors a call to super classes's constructor is implicitly made.

eg, If you write parent's constructor as following:


It would be interpreted like:


Please see the documentation http://docs.oracle.com/javase/specs/jls/se7/html/jls-8.html#jls-8.8
You can refer to any Java text book as well.

Regards
11 years ago
Thank you all for your replies

@Anayonkar, I could not find any method, getStackTraceDepth, in Throwable class. Checked in Java6 specifications. Please let me know if I am missing anything.

@Winston, I completely understand your view point but I have worked on a customized JVM for embedded devices where a maximum of 128 call depth was allowed. For standard Java this is not a constraint at all. I asked this question more from understanding point of view.

@Rob, I tried your test application and learnt what I wanted. Thanks again !
11 years ago
Is it possible to set the maximum number of call stack depth in Java?

I found that the non standard JVM argument (-Xss) is used to specify the maximum memory of a particular stack BUT not the number of frames in the stack.

Can anyone throw some light or provide any pointers?
11 years ago
Yes Jelle I noticed the difference. Tried serializing object of an ArrayList and a Vector filled with same objects.
In my case serialized ArrayList object took 230 bytes while serialized Vector object took 335 bytes of memory.
11 years ago
Yes, it is fine to have static member variable inside such class.
11 years ago
Thanks Jelle. I didn't know about the following:

Writing the array's size and actual contents instead of the entire array itself is slightly more efficiƫnt, because the array would add it's own overhead to the serialization process



Do you mind sharing the source of this information? Would do some study
11 years ago
Thanks for your reply Jesper. I understand the point that for ArrayList ConcurrentModificationException has to be thrown in case of modification while writing the object.
In ArrayList writeObject method looks like:

While for Vector it is:

What I want to understand is why ArrayList separately writes each element which doesn't happen for Vector.
Could we not have the following code for ArrayList:
>
11 years ago
Hi all

Could anyone please throw some light on why the serialization of Vector and ArrayList is handled differently?
The object element array used internally in ArrayList is marked transient but not in Vector. Vector uses default Serialization approach accept making the writeObject method synchronized while ArryList manually writes and reads every element.

Regards.
11 years ago
Why does the java.util.ArrayList class implements java.util.List interface?
As we know that ArrayList extends from java.util.AbstractList which already implements the List interface?
Is it a mistake or conscious design decision?

Regards
Girish K Gupta
11 years ago
Hi Rob

java.awt.Toolkit has a public constructor. It should not be a Singleton.

Thanks
Girish
11 years ago