Re: owfs memory consumption and timing questions
2009-04-01 02:26:18 GMT
I've added a small perl program to parse the output from the memory leak output at src/scripts/memleakparser.pl
Here it is:
#!/usr/bin/perl -w
# OWFS test program
# See owfs.sourceforge.net for details
# {copyright} 2004 Paul H. Alfille
# GPL v2 license
# $Id: owdir.pl,v 1.2 2009/04/01 01:26:35 alfille Exp $
use strict ;
die (
"$0 -- part of the 1-Wire Filesystem Suite (OWFS)\n"
."Syntax:\n"
."\t$0 < mem.txt\n"
."where mem.txt is the output from owserver\n\n"
."Basically, this program parses the memory allocation output, matching\n"
."allocation and free, and marking the unmatched lines with '!'\n\n"
."To use, owserver must be compiled with OW_ALLOC_DEBUG and invoked\n"
."\towserver -u -p 4304 --foreground > mem.txt\n\n"
."By Paul H Alfille 2009\n"
."See http://www.owfs.org\n"
) if ( $#ARGV >= 0 ) ;
my <at> lines = reverse(<>) ;
my <at> addr ;
my <at> status ;
foreach my $line ( <at> lines) {
$line =~ /^([0123456789abcdefABCDEFxXS]+) / ;
$addr[++$#addr] = $1 ;
if ($line =~ m/FREE/) {
$status[++$#status] = 1 ;
} else {
$status[++$#status] = 0 ;
}
}
my $count = $#lines ;
foreach (my $index = 0; $index <= $count ; ++$index) {
if ($status[$index] == 0) {
$lines[$index]="! ".$lines[$index] ;
} elsif ($status[$index] == 1) {
for (my $j = $index+1 ; $j <= $count ; ++$j) {
if ($addr[$index] eq $addr[$j]) {
if ($status[$j]==0) {
$lines[$index]="< ".$lines[$index] ;
$lines[$j]="> ".$lines[$j] ;
$status[$j] = -1 ;
} else {
$lines[$index]="! ".$lines[$index] ;
}
last ;
}
}
}
}
<at> lines = reverse( <at> lines);
printf join('', <at> lines) ;
Example output:
> 0x5f1d930 alloc owserver.c:main[113] STRDUP s=/opt/owfs-cvs3/bin/owserver
> 0x5f1d980 alloc ow_connect.c:NewIn[88] MALLOC size=848
> 0x5f1dd00 alloc ow_connect.c:NewOut[130] MALLOC size=256
> 0x5f1de30 alloc ow_ds9490.c:DS9490_detect[292] STRDUP s=-1/-1
< 0x5f1de30 free ow_ds9490.c:DS9490_open[425] FREE
> 0x5f2c708 alloc ow_ds9490.c:DS9490_device_name[584] STRDUP s=002/005
> 0x5f2c7a0 alloc ow_bus.c:BUS_send_data[35] MALLOC size=2
< 0x5f2c7a0 free ow_bus.c:BUS_send_data[46] FREE
! (nil) free ow_dirblob.c:DirblobAdd[82] REALLOC
> 0x5f2c7d8 alloc ow_dirblob.c:DirblobAdd[82] REALLOC size=80
! 0x5f2c858 alloc ow_cache.c:Cache_Add_Device[345] MALLOC size=44
! 0x5f2c908 alloc ow_cache.c:Cache_Add_Device[345] MALLOC size=44
! 0x5f2c9b8 alloc ow_cache.c:Cache_Add_Device[345] MALLOC size=44
! 0x5f2ca68 alloc ow_cache.c:Cache_Add_Device[345] MALLOC size=44
! 0x5f2cb18 alloc ow_cache.c:Cache_Add_Device[345] MALLOC size=44
! 0x5f2cbc8 alloc ow_cache.c:Cache_Add_Device[345] MALLOC size=44
> 0x5f2cdb8 alloc ow_net_server.c:ServerAddr[34] STRDUP s=0.0.0.0
> 0x5f2cdf0 alloc ow_net_server.c:ServerAddr[35] STRDUP s=4304
> 0x5f2ce98 alloc ow_net_server.c:ServerProcessAccept[231] MALLOC size=16
> 0x5f2d018 alloc from_client.c:FromClient[86] MALLOC size=27
> 0x5f2d1a8 alloc ow_parsename.c:FS_ParsedName_setup[256] STRDUP s=3A.1EDA01000000/PIO.ALL
> 0x5f2d1f0 alloc ow_parsename.c:FS_ParsedName_setup[261] MALLOC size=48
< 0x5f2d1a8 free ow_parsename.c:FS_ParsedName_anywhere[130] FREE
> 0x5f2d250 alloc ow_parseobject.c:FS_OWQ_create_postparse[71] CALLOC size=8 nmemb=2
> 0x5f2d290 alloc ow_locks.c:LockGet[166] MALLOC size=56
> 0x5f2d348 alloc ow_parsename.c:FS_ParsedName_setup[256] STRDUP s=3A.1EDA01000000/piostate
> 0x5f2d398 alloc ow_parsename.c:FS_ParsedName_setup[261] MALLOC size=50
< 0x5f2d348 free ow_parsename.c:FS_ParsedName_anywhere[130] FREE
! 0x5f2d400 alloc ow_parseobject.c:FS_OWQ_from_pn[86] MALLOC size=172
< 0x5f2d398 free ow_parsename.c:FS_ParsedName_destroy[73] FREE
> 0x5f2d4e0 alloc ow_bus.c:BUS_send_data[35] MALLOC size=1
In this example, the 3rd to last line is the error. (Parsing the whole thing demonstrates this.)
I'll work on it.
Paul Alfille
------------------------------------------------------------------------------
_______________________________________________ Owfs-developers mailing list Owfs-developers <at> lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/owfs-developers
RSS Feed