The WeakReference class, monitoring memory leak and garbage collection in a Java application

Image
 Below is a Stack implementation that uses an internal resizeable array structure.  public class MyStack< T > implements Stack< T > { private static final int CAPACITY = 100 ; private Object[] array ; private int pos = 0 ; public MyStack () { this . array = new Object[ CAPACITY ] ; } @Override public void push ( T item) { if ( pos >= array . length / 2 ) { Object[] newArray = new Object[ pos * 2 ] ; System. arraycopy ( array , 0 , newArray , 0 , array . length ) ; array = newArray ; } array [ pos ++] = item ; } @Override public T pop () { if (isEmpty()) { throw new RuntimeException( "empty stack" ) ; } @SuppressWarnings ( "unchecked" ) T item = ( T ) array [ pos - 1 ] ; pos -= 1 ; return item ; } @Override @SuppressWarnings ( "unchecked" ) public T peek...

More on Virtual Memory and TLB


Below is a series of videos on virtual memory:

https://www.youtube.com/watch?v=KNUJhZCQZ9c
  • Virtual memory is a layer of indirection. Without virtual memory the program address would be equal to the RAM address. 
  • Discs are 1000x slower than RAM.
  • What happens if a page is not on RAM? 
    • Page table tells that the page is on disc.
    • Hardware (CPU) generates a page fault exception.
    • This exception will be picked up by the operating system. (page fault handler)
    • Operating system kicks out (evicts) another page from RAM and writes it to disc
    • If the page is dirty, it needs to be written back to disc first.
    • Then OS reads the page from disk and puts it in RAM
    • Then OS updates the page table to map the new page
    • Finally OS jumps back to the instruction that caused the page fault
    • A page fault is the slowest possible thing that can happen to a computer. (except for human interaction)
  • Some operating sytems do not use paging:
    • iOS kills the program if it uses too much memory.
  • TLB should be fast, we have to use it for every memory access. Do there are seperate TLBs for instructions and data (iTLB/dTLB) 

  • For iTLB, if the CPU reads the instuctions from the same page, we can put the iTLB to low leakage mode, which decreases the energy usage.
    • But how will we know when the current page will be left? (So that we switch the iTLB to the normal energy mode)
    • First step: run SPEC benchmarks on normal SuperScalar configuration. 
    • Second step: How to implement low energy mode for iTLB.
      • Put it on low energy mode all the time, and see the benchmark results.
    • Third Step: How to guess the time when the current page is left. Implement.

Lecture on simulators:

https://www.youtube.com/watch?v=yfKk4GcBMi8&t=206s

An article on SimpleScalar:

http://www.dre.vanderbilt.edu/~sutambe/documents/pubs/wcre2004.pdf

Modified Version of SimpleScalar:

https://github.com/aivus/SimpleScalar

Visual C++ notes:

http://stackoverflow.com/questions/16883037/remove-secure-warnings-crt-secure-no-warnings-from-projects-by-default-in-vis

Library Directories:
C:\Program Files (x86)\Windows Kits\10\Lib\10.0.10150.0\ucrt\x86

C/C++ Additional Include Libraries:
C:\Program Files (x86)\Windows Kits\10\Include\10.0.10150.0\ucrt


http://stackoverflow.com/questions/31736361/visual-studio-2015-gives-me-errors-upon-creating-a-simple-test-console-program

Building simplescalar on linux is easy as described in readme file.





Comments

Popular posts from this blog

Trie Data Structure and Finding Patterns in a Collection of Words

My Crappy Looking Solution to "Binary Tree Common Ancestor" Problem

A Graph Application in Java: Using WordNet to Find Outcast Words