get RSS-size in Solaris #845

Open
qudreams opened this Issue Dec 22, 2012 · 0 comments

Comments

Projects
None yet
1 participant
@qudreams

The function zmalloc_used_memory can't get the RSS-size of Redis process properly.
We can get RSS-size in solaris preperly lik this:

/*
 *the struct psiinfo_t is included in the file procfs.h
 */
#include <procfs.h>
#include <string.h>
size_t zmalloc_get_rss(void){
    size_t rss = 0;
    char filename[256] = {0};
    FILE* fp = NULL;
    psinfo_t psinfo;
    memset((void*)&psinfo,0,sizeof(psinfo));
    snprintf(filename,sizeof(filename),"/proc/%ld/psinfo",(long)getpid());
    if((fp = fopen(filename,"r")) == NULL)
         rss = zmalloc_used_memory();
    else
    {
        if(fread((void*)&psinfo,sizeof(psinfo),1,fp) != 1)
            rss = zmalloc_used_memory();
        else
            rss = psinfo.pr_rssize * 1024;/*pr_size is in Kbytes*/
        fclose(fp);
    }
    return rss;
}

Please fix it.

@qudreams qudreams closed this Dec 22, 2012

@qudreams qudreams reopened this Dec 22, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment