Android Low Memory Killer + kswapd

1,659 views
Skip to first unread message

Raja Pavan

unread,
Nov 18, 2010, 12:39:03 AM11/18/10
to Android Linux Kernel Development
We are testing the lowmemorykiller.c driver of android, using a sample
test application that malloc() and memset() memory. [code pasted
below]

void loopmalloc()
{
int size,i=0;
float **ptr = NULL;

printf("\n\nLoopMalloc starts....\n\n");
ptr = (float **)malloc(2000000*sizeof(float *));
while(i++ < 2000000)
{
printf("LoopMalloc Starts i=%d\n",i);
size = 1024*1024*1024*sizeof(float);
ptr[i] = (float *)malloc(size);
memset(ptr[i],0,size);
}
}

We configured lowmemorykiller.c to be triggrred for 6 different levels
of freememory

init.rc
write /sys/module/lowmemorykiller/parameters/minfree
1536,2048,4096,5120,5632,6144

Low Memory Killer was not tiggerred for any level of the freememory
mentioned above.

Then we increased the Free Memory Levels, so the sample application is
expected to be triggered at the very beginning as we have configured
the LMK to be triggered even for a very high free memory.

write /sys/module/lowmemorykiller/parameters/minfree
1054720,1054720,1054720,1054720,1054720,1054720

Now the low memory killer is getting called and also the sample test
application is killed by the lowmemorykiller.

But only after the sample application is almost at the end of the
memory allocation.

Is there any patch to lowmemorykiller.c or the kswapd (mm/vmscan.c)
that will make the lowmemorykiller to get triggerred for all levels of
the free memory levels specified inside the init.rc.

Dianne Hackborn

unread,
Nov 18, 2010, 3:21:47 PM11/18/10
to android...@googlegroups.com
What oom_adj is your test app running under?




--
Dianne Hackborn
Android framework engineer
hac...@android.com

Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails.  All such questions should be posted on public forums, where I and others can see and answer them.

raja pavan

unread,
Nov 18, 2010, 11:50:42 PM11/18/10
to android...@googlegroups.com
(1) We are three launching processes which seek large chunks of memory from the system.
 
- Our application from init.rc (oom_adj = -16), later changed to 13, cpu consumtion 7%
- Test application  (memoryeater) from shell (oom_adj = 0) , later changed to 12
- Android Calculator application (oom_adj = -16)
 
We are tracking the free memory available in the system using 'free' command from shell.
We are setting minfree to 1054720 , anticipating the LOWMEMORYKILLER to trigger very early.
 
But the lowmemory killer is triggerred almost at the end of the memoryeater loop.
 
Thanks
Raja

Dianne Hackborn

unread,
Nov 19, 2010, 12:39:55 AM11/19/10
to android...@googlegroups.com
None of those oom_adj levels are going to do you any good, since those are all considered critical or nearly critical processes.  Please look at the oom_adj levels that are defined in init.rc right around where the memory thresholds are which provides the binning for the different memory levels.

ksam

unread,
Jan 27, 2014, 4:31:17 AM1/27/14
to android...@googlegroups.com
Hi Raja Pawn,

I am trying to test the low memory killer driver. I am not able to simulate it.

On Thursday, November 18, 2010 11:09:03 AM UTC+5:30, Raja Pavan wrote:
We are testing the lowmemorykiller.c driver of android, using a sample
test application that malloc() and memset() memory. [code pasted
below]

void loopmalloc()
{
    int size,i=0;
    float **ptr = NULL;

    printf("\n\nLoopMalloc starts....\n\n");
    ptr = (float **)malloc(2000000*sizeof(float *));
    while(i++ < 2000000)
    {
       printf("LoopMalloc Starts i=%d\n",i);
       size = 1024*1024*1024*sizeof(float);
       ptr[i] = (float *)malloc(size);
       memset(ptr[i],0,size);
    }
}

I am also using the same method to allocate the memory
.
We configured lowmemorykiller.c to be triggrred for 6 different levels
of freememory

init.rc
write /sys/module/lowmemorykiller/parameters/minfree
1536,2048,4096,5120,5632,6144

Low Memory Killer was not tiggerred for any level of the freememory
mentioned above.

Then we increased the Free Memory Levels, so the sample application is
expected to be triggered at the very beginning as we have configured
the LMK to be triggered even for a very high free memory.

write /sys/module/lowmemorykiller/parameters/minfree
1054720,1054720,1054720,1054720,1054720,1054720

Do we need to set these values when we are booting the device or we can change the values using adb.
Because as I am modifying these values by echoing, still the lowmem_shrink is not getting invoked. 
Reply all
Reply to author
Forward
0 new messages