[Webkit-unassigned] [Bug 91214] [EFL] Add WebMemorySampler feature.
bugzilla-daemon at webkit.org
bugzilla-daemon at webkit.org
Tue Aug 28 07:03:30 PDT 2012
https://bugs.webkit.org/show_bug.cgi?id=91214
--- Comment #44 from Simon Hausmann <hausmann at webkit.org> 2012-08-28 07:03:31 PST ---
(From update of attachment 160928)
View in context: https://bugs.webkit.org/attachment.cgi?id=160928&action=review
> Source/WebKit2/PlatformEfl.cmake:33
> + Shared/linux/WebMemorySamplerLinux.cpp
Excellent! :)
> Source/WebKit2/Shared/linux/WebMemorySamplerLinux.cpp:96
> +static void sampleSystemMemoryInfo(WebMemoryStatistics& statics)
> +{
> + bool foundKeyName = false;
> + FILE* fSystemMemoryStatus = fopen("/proc/meminfo", "r");
> + if (!fSystemMemoryStatus)
> + return;
> +
> + while (!feof(fSystemMemoryStatus)) {
> + String strToken = getToken(fSystemMemoryStatus);
> + if (strToken.find(':') != notFound) {
> + String keyName = strToken.left(strToken.length() - 1);
> + statics.keys.append(keyName);
> + foundKeyName = true;
> + } else if (foundKeyName) {
> + statics.values.append(strToken.toInt());
> + foundKeyName = false;
> + }
> + }
> + fclose(fSystemMemoryStatus);
> +}
I think instead of parsing /proc/meminfo you could use sysinfo(2) to get the same information with simpler code (no need to use insecure fscanf).
> Source/WebKit2/Shared/linux/WebMemorySamplerLinux.cpp:103
> + char processPath[maxProcessPath];
> + snprintf(processPath, maxProcessPath, "/proc/%d/statm", getpid());
> + FILE* fMemoryStatus = fopen(processPath, "r");
I think you can simplify this to
FILE* fMemoryStatus = fopen("/proc/self/statm", "r");
or alternatively get try to get the same information using getrusage(2) and getrlimit(2).
I think a programmatic approach is nicer than parsing files in /proc.
--
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
More information about the webkit-unassigned
mailing list