Professional Documents
Culture Documents
Report
On
MEMORY MANAGEMENT
BACHELOR OF ENGINEERING
IN
Submitted By:-
JYOTI POONIA
Submitted To:-
HEAD
Mr. AJEET SINGH POONIA
College of Engineering & Technology, Bikaner
(An Autonomous Institute of Govt. of Rajasthan)
Acknowledgement
JYOTI POONIA
CSE IV year
Table of content
1. Definition
3. Getting started
4. Performance Metrics
5. Perceived Performance
7. Topics
8. Agenda
9. Theory
10. bibliography.
Definition: Performance Monitoring
• Performance metrics
• Development process.
Getting started ::
• Performance tuning is largely an art.
• There is no one approach that is always necessarily the right
approach.
• And, there are performance issues which will require very specialized
expertise to identify the root cause, and / or be able to recommend a
solution.
Performance Metrics:
• Throughput
• Footprint
• Ways to improve how fast your users feel without actually making
anything run faster
• Startup time:
• cpu
> vmstat (Solaris & Linux)
> mpstat (Solaris)
> prstat (Solaris)
> top (Linux, prefer prstat on Solaris)
> Task Manager (Windows)
> Performance Monitor (Windows)
> xosview (Linux)
> cpubar (Solaris – Performance Tools CD)
> iobar (Solaris – Performance Tools CD)
> dtrace (Solaris)
vmstat :
• Idle cpu
> On multi-threaded applications and multi-core systems, idle
cpu can be an indicator of an application's inability to scale.
> Combination of high sys or kernel CPU utilization and idle
CPU could indicate shared resource contention as the
scalability blocker.
Swing and its Feature
Line2D
This Line2D represents a line segment in (x,y) coordinate space. This class,
like all of the Java 2D API, uses a default coordinate system called user
space in which the y-axis values increase downward and x-axis values
increase to the right. For more information on the user space coordinate
system, see the Coordinate Systems section of the Java 2D Programmer's
Guide.
This class is only the abstract superclass for all objects that store a 2D line
segment. The actual storage representation of the coordinates is left to the
subclass.
our application, we must import the javax. Swing package as we done in
our project. The package contains the classes and interface that support
and manage the GUI components. Swing Components are platform-
independent and therefore are termed as lightweight.
Events
The classes with names ending in "Event" represent specific types of events, generated by
the AWT or by one of the AWT or Swing components.
Listeners
The interfaces in this package are all event listeners; their names end with "Listener".
These interfaces define the methods that must be implemented by any object that wants to
be notified when a particular event occurs. Note that there is a Listener interface for
each Event class.
Platform MXBeans
This package defines the management interface of the following
components:
Compilation system of
{@link java.lang.management.CompilationMXBean} the Java virtual
machine.
Memory system of
{@link java.lang.management.MemoryMXBean} the Java virtual
machine.
Runtime system of
{@link java.lang.management.RuntimeMXBean} the Java virtual
machine.
Operating system on
{@link
which the Java virtual
java.lang.management.OperatingSystemMXBean}
machine is running.
Garbage collector in
{@link
the Java virtual
java.lang.management.GarbageCollectorMXBean}
machine.
Memory manager in
{@link
the Java virtual
java.lang.management.MemoryManagerMXBean}
machine.
A platform MXBean is a managed bean that defines the management interface for one
component for the platform and is specified in the ManagementFactory class.
An application can monitor the instrumentation of the Java virtual machine and manage certain
characteristics in the following ways:
import java.awt.*;
import java.awt.event.*;
import java.awt.image.BufferedImage;
import java.awt.geom.Line2D;
import java.awt.geom.Rectangle2D;
import java.util.Date;
import javax.swing.*;
import javax.swing.border.EtchedBorder;
import javax.swing.border.TitledBorder;
import java.lang.management.*;
import java.util.*;
JPanel controls;
boolean doControls;
JTextField tf;
ManagementFactory.getMemoryPoolMXBeans();
public MemoryMonitor() {
setLayout(new BorderLayout());
controls.setPreferredSize(new Dimension(135,80));
label.setFont(font);
label.setForeground(Color.red);
controls.add(label);
tf = new JTextField("1000");
tf.setPreferredSize(new Dimension(45,20));
controls.add(tf);
label.setFont(font);
label.setForeground(Color.red);
controls.add(dateStampCB);
dateStampCB.setFont(font);
addMouseListener(new MouseAdapter() {
removeAll();
if ((doControls = !doControls)) {
surf.stop();
add(controls);
} else {
try {
surf.sleepAmount = Long.parseLong(tf.getText().trim());
surf.start();
add(surf);
validate();
repaint();
});
private int w, h;
public Surface() {
setBackground(Color.black);
addMouseListener(new MouseAdapter() {
});
int i = 0;
usedMem = new float[numPools][];
return getPreferredSize();
return getPreferredSize();
if (big == null) {
return;
big.setBackground(getBackground());
big.clearRect(0,0,w,h);
plotMemoryUsage(w*i,h*j,w,h,k);
i = 3;
j = (numPools + numPools%2)/ 2;
break;
g.drawImage(bimg, 0, 0, this);
}
public void plotMemoryUsage(int x1, int y1, int x2, int y2, int
npool) {
MemoryPoolMXBean mp = mpools.get(npool);
(float) y1 + ascent+0.5f);
big.setColor(Color.yellow);
usedStr = String.valueOf((int)usedMemory/1024)
+ "K used";
big.setColor(Color.green);
// .. Memory Free ..
big.setColor(mfColor);
int i = 0;
mfRect.setRect(x1+5,(float) y1+ssH+i*blockHeight,
blockWidth,(float) blockHeight-1);
big.fill(mfRect);
// .. Memory Used ..
big.setColor(Color.green);
muRect.setRect(x1+5,(float) y1 + ssH+i*blockHeight,
blockWidth,(float) blockHeight-1);
big.fill(muRect);
big.setColor(graphColor);
int graphX = x1+30;
big.draw(graphOutlineRect);
// .. Draw row ..
graphLine.setLine(graphX,j,graphX+graphW,j);
big.draw(graphLine);
if (columnInc == 0) {
columnInc = graphColumn;
graphLine.setLine(j,graphY,j,graphY+graphH);
big.draw(graphLine);
--columnInc;
if (usedMem[npool] == null) {
ptNum[npool] = 0;
usedMem[npool][ptNum[npool]] = usedMemory;
big.setColor(Color.yellow);
w1 = graphW;
} else {
w1 = ptNum[npool];
k++, j++) {
if (k != 0) {
if (usedMem[npool][k] != usedMem[npool][k-1]) {
usedMem[npool][k-1])/totalMemory));
usedMem[npool][k])/totalMemory));
} else {
usedMem[npool][k])/totalMemory));
if (ptNum[npool]+2 == usedMem[npool].length) {
usedMem[npool][j-1] = usedMem[npool][j];
--ptNum[npool];
} else {
ptNum[npool]++;
thread.setPriority(Thread.MIN_PRIORITY);
thread.setName("MemoryMonitor");
thread.start();
thread = null;
notify();
Thread me = Thread.currentThread();
try {
thread.sleep(500);
Dimension d = getSize();
if (d.width != w || d.height != h) {
w = d.width;
h = d.height;
big = bimg.createGraphics();
big.setFont(font);
FontMetrics fm = big.getFontMetrics(font);
repaint();
try {
thread.sleep(sleepAmount);
if (MemoryMonitor.dateStampCB.isSelected()) {
}
thread = null;
Object y[];
public Memeater() {}
y = new Object[10000000];
int k =0;
while(true) {
if (k == 5000000) k=0;
try {
Thread.sleep(20);
try {
} catch (ClassNotFoundException x) {
// ignore exception
// public TestNNNNNN();
// Code:
// 0: aload_0
// 4: return
// }
int begin[] = {
int end [] = {
// TestNNNNNN
byte value[];
try {
value = name.substring(4).getBytes("UTF-8");
} catch (java.io.UnsupportedEncodingException x) {
int i, pos=0;
b[pos++] = (byte)begin[i];
b[pos++] = value[i];
b[pos++] = (byte)end[i];
};
f.addWindowListener(l);
f.getContentPane().add("Center", demo);
f.pack();
f.setSize(new Dimension(400,500));
f.setVisible(true);
demo.surf.start();
thr.start();
Bibliography: -
JAVA:
The Complete reference Java 5
Herbert Schildt
JDBC Notes
Software Engineering:
Software Engineering
Roger S.Pressma