MCPcopy Index your code
hub / github.com/callstack/agent-device / parseAndroidMemInfoSample

Function parseAndroidMemInfoSample

src/platforms/android/perf.ts:244–281  ·  view source on GitHub ↗
(
  stdout: string,
  packageName: string,
  measuredAt: string,
)

Source from the content-addressed store, hash-verified

242}
243
244export function parseAndroidMemInfoSample(
245 stdout: string,
246 packageName: string,
247 measuredAt: string,
248): AndroidMemoryPerfSample {
249 if (/no process found for:/i.test(stdout)) {
250 throw new AppError(
251 'COMMAND_FAILED',
252 `Android meminfo did not find a running process for ${packageName}`,
253 {
254 metric: 'memory',
255 package: packageName,
256 hint: 'Run open <app> for this session again to ensure the Android app is active, then retry perf.',
257 },
258 );
259 }
260
261 const totalPssKb = matchLabeledNumber(stdout, 'TOTAL PSS') ?? matchTotalRowPss(stdout);
262 if (totalPssKb === undefined) {
263 throw new AppError(
264 'COMMAND_FAILED',
265 `Failed to parse Android meminfo output for ${packageName}`,
266 {
267 metric: 'memory',
268 package: packageName,
269 hint: 'Retry perf after reopening the app session. If the problem persists, capture adb shell dumpsys meminfo output for debugging.',
270 },
271 );
272 }
273
274 return {
275 totalPssKb,
276 totalRssKb: matchLabeledNumber(stdout, 'TOTAL RSS'),
277 measuredAt,
278 method: ANDROID_MEMORY_SAMPLE_METHOD,
279 topConsumers: parseAndroidMemInfoTopConsumers(stdout),
280 };
281}
282
283async function resolveAndroidAppPid(adb: AndroidAdbExecutor, packageName: string): Promise<number> {
284 const result = await adb(['shell', 'pidof', packageName], {

Callers 2

perf.test.tsFile · 0.90
sampleAndroidMemoryPerfFunction · 0.85

Calls 3

matchLabeledNumberFunction · 0.85
matchTotalRowPssFunction · 0.85

Tested by

no test coverage detected