Sun Studio compiler collection bundles a set of tools for collecting and analyzing performance data from an application. Collector & Analyzer, a pair of tools from Sun Studio suite that we use to collect and analyze the performance data. Both tools can be used from the command line or from a graphical user interface.

These two tools help answering the following questions:

How much of the available resources does the program consume?

Which functions or load objects are consuming the most resources?

Which source lines and instructions are responsible for resource consumption?

How did the program arrive at this point in the execution?

Which resources are being consumed by a function or load object?

But this blog post mainly concentrates on finding memory leaks from the following simple C program

From the code, it is clear that the program is requesting memory allocations four times (a total of 725 bytes); but releasing only 25 bytes from virtual memory. The following steps explain how to find this 700 byte leak with Collector/Analyzer.

Prepare the program for data collection

To see source code in annotated source and disassembly, and source lines in the line analysis, the source file must be compiled with -g compiler option to generate debug symbol information% CC -g -o mem mem.c

Collect the data

We can collect run-time data that is useful for later analysis by running the executable under collect utility. To see the entire list of arguments that collect accepts, type collect without any arguments on the command line. Since we were interested in memory leaks, we have to turn the heap tracing on with -H option. (By default, heap tracing is off). Also we have to supply an experiment name to hold the data with -o option% which collect/opt/SUNWspro/prod/bin/collect

source allocate shows the annotated source with line numbers and number of bytes leaked from each line since we collected the data with heap tracing on (otherwise it shows the total CPU time spent in each line, by default)

From the annotated source, we can see that 700 bytes were leaked after the execution of line:

## 700 3 0. 0. 21. allocate();

. And from the source of allocate(), the following lines were the culprits:

statement was clean, since we have 0 0 0. 0. 17. free (y); at the end of function allocate().

We can also get much useful information with the help of leaks and allocs commands that relate to memory allocations and deallocations. Brief description of those commands are as follows:

leaks

Display a list of memory leaks, aggregated by common call stack. Each entry presents the total number of leaks and the total bytes leaked for the given call stack. The list is sorted by the number of bytes leaked.

allocs

Display a list of memory allocations, aggregated by common call stack. Each entry presents the number of allocations and the total bytes allocated for the given call stack. The list is sorted by the number of bytes allocated.

On Solaris SPARC, we need the GNU C/C++ Compiler; it does not matter if GNU C/C++ compiler is configured with or without the GNU assembler

On Solaris x86, we need the GNU assembler and the GNU C/C++ compiler, configured to use the GNU assembler. The MPlayer code on the x86 platform makes heavy use of MMX, SSE and 3DNOW! instructions that cannot be compiled using Sun's assembler /usr/ccs/bin/as

Error message from configure on a Solaris x86 system using GCC without GNU assembler

If the machine is connected to the network during the installation of the OS (Solaris in this case), the operating system takes care of setting up the dhcp (Dynamic Host Configuration Protocol) client for us. But if the machine is not hooked up to a network during the installation, we may have to set it up on our own once the machine is ready to use the network services. Infact it is a very simple process to setup and run dhcp client, which in turn takes care of getting the dynamic IP, DNS etc., from a DHCP server

All we need to do is to create couple of files for the ethernet interface.

To get the interface name for ethernet, type dmesg | grep ether. Let's assume that it is elxl0

Creating this file ensures that the interface gets plumbed. By plumbing, it implements the TCP/IP stack ie., the OS sets up the streams needed for TCP/IP to use the device and makes it ready for the DHCP software to do its stuff

Behind the scenes: During the boot process, the OS reads all the /etc/hostname.* files and plumbs the devices. Once plumbed, the devices are configured by reading the /etc/hosts and the /etc/netmasks file

Next step is to create /etc/dhcp.<ether interface>. eg., touch /etc/dhcp.elxl0This file can be empty if you want to accept the defaults, but may also contain one or both of the following directives:

wait time, and

primary

By default, ifconfig will wait for 30 sec for the DHCP server to respond and then the boot process continues, while the interface gets configured in the background. Specifying the wait directive tells ifconfig not to return until the DHCP has responded. The primary directive indicates to ifconfig that the current interface is the primary one, if you have more than one interface under DHCP control. If you have only one interface under DHCP control, then it is automatically the primary one; so primary is redundant, although it's permissible

It is important to note that the dhcp client daemon, dhcpagent will be started only if /etc/dhcp.interface file exists. With these files in place, subsequent reboots will place the ethernet interface under DHCP control and the machine will be ready to access network services

Fact: Comcast doesn't support any OS except Windows & Mac. It doesn't mean that Unix/Linux users can not access internet with Comcast services; but it means Comcast refuses to trouble shoot any issues on *nix platform ie., *nix users are on their own to fix any of the issues

In general, Comcast technician leaves a CD-ROM to activate the Comcast account, once the installation is done. The activation wizard of the CD takes care of registering the modem, activating the account for us. Unfortunately it works only on Windows and Mac platforms

However Comcast is kind enough to provide web interface for activating the account (some people refer it as "registering the modem"; Comcast refers it as "Activating the ISP"). Comcast uses DHCP (Dynamic Host Configuration Protocol) for IP assignment. So, if we have a DHCP client running on the machine, it contacts the Comcast's DHCP server(s) and obtains a valid IP, DNS info etc., ie., As soon as the cable modem installation is done, our machine will be on the network (to verify, simply try arp <any well known hostname>); but we can't actually access any of the public web sites due to the pending registration. Since we are in the network of Comcast, we will be able to access few web sites of Comcast, with the help of Comcast's proxy server. URLs for Comcast's primary proxy servers are as follows:

Configure your browser to use the Comcast's proxy server for your geographic region (see above for the list)

HTTP & SSL proxies must be configured to use the proxy server of your region

8000 is the port for both HTTP & SSL proxies

Fill out "No Proxy for:" field with the name of the proxy server for your region without the string "https://sas." from the actual URL

Now try to access the proxy server URL for your region. Hopefully you should be able to see a page with two fields: Account Number and Registration Code. Account Number is the Subscriber Number and Registration Code is the number (ID) that you may find under "Service Name and Address" field of the invoice you received from Comcast.

As you proceed to the next step, you will be also be prompted to setup your Comcast e-mail account

Once the device (modem) is registered, the web page shows a link to restart the cable modem. Go ahead and restart the modem. If you are using a router, you need to restart the modem as well. To restart the router: turn the power off, wait for a min and then turn it back on.

Now your account is activated; but you still can not access public web sites due to Comcast's proxy server configuration. Since we do not need it anymore, go back to web browser's proxy configuration window and choose "Direct connection to the internet"

If you can not access internet even at this point, try to restart the network or the machine depending on your expertise level. Even if it didn't help, try calling Comcast support center and find out the the proxy server, that you need to use in your region

PS:The above steps are equally applicable for other platforms as well; but Unix, Linux were explicitly added to the title for Google feed