Probability of rising trend My goal is to detect memory leaks in a computer system. 
Let
$S=\{s_1, s_2, ..., s_n\}$
be a series of differences in memory usage. If $s_1$ is greater than $0$ it means that the memory usage has increased $s_1$ kB between sample $0$ and sample $1$, and if it's negative the memory usage has decreased.
A rudimentary memory leak detection algorithm is to count the number of positive values in $S$ and divide that sum with $n$. If the ratio is above a certain threshold, it can be an indication of a leak. I've tried this, and unfortunately this method gives too many false positives. This method will also fail if memory is returned in larger chunks than it is allocated.
I'm now thinking about some kind of least square estimation $L$ of $S$. If the probability of a positive slope of $L$, taking in account the number of samples in $S$ and the standard deviation of those samples, is greater than a certain threshold value (maybe $99\%$), it will be considered a leak.
What do you think? Can this be a good method? If so, is there any standard procedure for doing these calculations? 
I will do the implementation in Java, so if there are any good libraries it's a plus.
 A: It seems your current method does not account for chance variation.
Sort of like declaring a coin unfair if you get slightly more than
25 heads in 50 tosses. In that example, 32 or more Heads out of 50 might make
a good case for declaring the coin unfair.
So if there are $X$ positive indications in a string of $n$ determinations
of memory usage, a somewhat crude but certainly improved method
would be to look at $\tilde p \pm 1.96\sqrt{\tilde p(1-\tilde p)/(n+4)},$
where $\tilde p = (X+2)/(n+4),$ declaring a problem exists if this 
interval does not contain 1/2.
But there is more information in the $s_i$'s than just whether they
are positive or negative. In the field of quality management, there
is a vast literature on 'control charts'. There may be a kind of control
chart that would be effective and easy to use.
In your question, you hint at something like doing a regression of
the $s_i$ against $t_i$ (times of meassurement). In that case, there is a test to see whether
the slope of the regression line is significantly positive. The standard
version of this assumes that the model is $s_i = \beta_0 + \beta_1 t_i + e_i,$
where the $e_i$ are a random sample from $Norm(0, \sigma),$ with constant
$\sigma.$ Without seeing your data, I have no idea whether they come close enough to such a model for a regression approach to be useful. More elaborate kinds
of 'time series' analysis might be better.
Of these approaches, I would recommend you start with control charts.
The ideas are simple and flexible, and there is a long record of profitable
use.
