• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Give me a code for this please!

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Our teacher in the university gave us the following exercise and i have no idea how to process it so if someone could give me a code for this i would be very thankful.
Here is the exercise :

Class Runtime of java.lang package includes some simple methods that can
help you gain a better sense of what the garbage collector of java does.A
Runtime object maintains information about the state of the virtual machine of Java. If you want to
examine this information , you can get the current runtime environment by calling
Static methods getRuntime () and store the result in a variable , like this:
Runtime myRuntime Runtime.getRuntime ();
Once you have this variable you can find how much free memory is available with
call
myRuntime.freeMemory ();
As memory sizes can be large , the return value is the number freeMemory is long instead
for int and indicates the number of byte that are available . You can also explicitly enable the
garbage collector by calling
myRuntime.gc ();
Write a program that distributes 10,000 objects of type Rational without stores them in variables
so that everything becomes waste . After you do , measure the amount of free memory before and
after garbage collection , and use the difference to indicate how many byte released ,
as shown in the following sample :


Allocating 10000 Rational objects
Garbage collection freed 94140

 
Sheriff
Posts: 5555
326
IntelliJ IDE Python Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry but here at the Ranch we encourage you to DoYourOwnHomework (<-- click).

However, if you ShowSomeEffort (<-- click) and come back with any specific problems you may have then we'll gladly help you.
 
lowercase baba
Posts: 13089
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
start by reading this:

StopCoding (<---click that and READ the page)
reply
    Bookmark Topic Watch Topic
  • New Topic