aboutsummaryrefslogtreecommitdiff
path: root/sys/nmemio/mfini.x
blob: f3933fa1ba64e02e26d46ee726a6e577e871c0b9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.

include <syserr.h>
include	<config.h>


define	MDEBUG		false

# MEM_FINI --  Close out the MEMIO use in this task.  We perform the memory
# garbage collection and report usage statistics if requested.

procedure mem_fini (task)

char 	task[ARB]			# task name

int	sv_report

include	"nmemio.com"

begin
	# Do garbage collection.
	call mgc_collect()
            
	# Turn off reporting so the print statements below don't add
	# to the reported values.
	sv_report = mreport
	mreport   = 0
	mdebug    = 0
	in_task   = 0

	if (MDEBUG) {
	    call eprintf ("\nTask '%s':\n")
                call pargstr (task)
	    call eprintf ("     mwatch:\t%d\n") ; call pargi (mwatch)
	    call eprintf ("     mclear:\t%d\n") ; call pargi (mclear)
	    call eprintf ("   mcollect:\t%d\n") ; call pargi (mcollect)
	    call eprintf ("    mreport:\t%d\n") ; call pargi (mreport)
	}

	# Report memory usage.
	if (sv_report > 0) {
            call eprintf ("\nTask '%s':\n")
                call pargstr (task)
	    call eprintf ("       Memory:\t%9d used   (%9d max )\n")
		call pargl (mem_used)
		call pargi (max_alloc)
	    call eprintf ("     Pointers:\t%9d alloc  (%9d free)\n")
		call pargi (nalloc)
		call pargi (nfree)
	    call eprintf ("       Leaked:\t%9d bytes  (%9d ptrs)\n\n")
		call pargl (leaked)
		call pargl (nleaked)
	}

	# Free the GC buffer.
	call mgc_close ()
end