Question: So I wrote this (Actually trying to see if realloc was O(n)-ish or not):

```
int main() {
time_t t1,t2;
char* x=malloc(sizeof(char));
char* y=x;
printf("%p %p\n",(void*)x,(void*)y);
double tot_time=0.0;
double time_r=0.0;
size_t s=2;
for(;;s++) {
    t1=clock();
    x=realloc(x,s*sizeof(char));
    t2=clock();
    if(x!=y) break;
    time_r=difftime(t2,t1)/CLOCKS_PER_SEC;
    //printf("%p %p %zu %f secs\n",(void*)x,(void*)y,s,time_r);
    tot_time+=time_r;
}

printf("%zu elements %f secs\n",s,tot_time);
return 0;}

```

Which reallocs with a constantly incrementing size (by 1 byte) the memory returned by malloc at the beggining until a different address is returned. When such thing happens, it will tell you how much memory was possible to alloc after that initial address returned by malloc. 

My question is: On a machine running Linux (In my case Ubuntu 14.04 64bits) is there any way to know before hand how much can the memory pointed to by x expand?

Answer: 
The problem is `FrameLayout` has `Views` as children. The replace method will replace only prior fragments, if any added in the `FrameLayout` NOT the views. 

To solve this, you could remove, the children from the `FrameLayout` and add it to a separate `Fragment`. Then add that `Fragment` in the `FrameLayout` as its only child in your XML.

Then when you `replace` the `Fragment` it will eventually get replaced.
try this

```
<ListView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/listView"
    />

    <ProgressBar
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/progressBar"
        android:layout_centerVertical="true"
        android:layout_centerHorizontal="true"
        android:layout_gravity="center" />
</FrameLayout>

```