74 } |
74 } |
75 iLowOnMemWgs.Reset(); |
75 iLowOnMemWgs.Reset(); |
76 User::LeaveIfError(iAlfClient.GetListOfInactiveWindowGroupsWSurfaces(&iLowOnMemWgs)); |
76 User::LeaveIfError(iAlfClient.GetListOfInactiveWindowGroupsWSurfaces(&iLowOnMemWgs)); |
77 |
77 |
78 RArray<TInt>& inactiveSurfaces = iLowOnMemWgs; |
78 RArray<TInt>& inactiveSurfaces = iLowOnMemWgs; |
79 |
79 TRACES1("Inactive surfaces count %d", inactiveSurfaces.Count()); |
80 RArray<TUint64> processIds; |
80 RArray<TUint64> processIds; |
81 RArray<TUint> privMemUsed; |
81 RArray<TUint> privMemUsed; |
82 |
82 RArray<TUint64> sparedProcessIds; |
83 if (inactiveSurfaces.Count() == 1) // ALF only |
83 |
84 { |
84 //if (inactiveSurfaces.Count() == 1) // ALF only |
|
85 // { |
85 NOK_resource_profiling eglQueryProfilingData = (NOK_resource_profiling)eglGetProcAddress("eglQueryProfilingDataNOK"); |
86 NOK_resource_profiling eglQueryProfilingData = (NOK_resource_profiling)eglGetProcAddress("eglQueryProfilingDataNOK"); |
86 |
87 |
87 if (!eglQueryProfilingData) |
88 if (!eglQueryProfilingData) |
88 { |
89 { |
89 TRACES("RefreshL EGL_NOK_resource_profiling not available"); |
90 TRACES("RefreshL EGL_NOK_resource_profiling not available"); |
91 } |
92 } |
92 |
93 |
93 EGLint data_count; |
94 EGLint data_count; |
94 EGLint* prof_data; |
95 EGLint* prof_data; |
95 TInt i(0); |
96 TInt i(0); |
96 RArray<TUint64> processIds; |
|
97 RArray<TUint> privMemUsed; |
|
98 RArray<TUint64> systemProcessIds; |
|
99 |
97 |
100 EGLDisplay dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY); |
98 EGLDisplay dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY); |
101 |
99 |
102 /* Find out how much profiling data is available */ |
100 /* Find out how much profiling data is available */ |
103 eglQueryProfilingData(dpy, EGL_PROF_QUERY_GLOBAL_BIT_NOK| |
101 eglQueryProfilingData(dpy, EGL_PROF_QUERY_GLOBAL_BIT_NOK| |
146 privMemUsed.Append(mem); |
144 privMemUsed.Append(mem); |
147 |
145 |
148 TRACES1("Memory Usage by app is %d", mem); |
146 TRACES1("Memory Usage by app is %d", mem); |
149 if(mem > KAllowedMemUsageForApps) |
147 if(mem > KAllowedMemUsageForApps) |
150 processIds.Append(process_id); |
148 processIds.Append(process_id); |
|
149 else |
|
150 sparedProcessIds.Append(process_id); |
151 |
151 |
152 i++; |
152 i++; |
153 break; |
153 break; |
154 } |
154 } |
155 case EGL_PROF_PROCESS_USED_SHARED_MEMORY_NOK: |
155 case EGL_PROF_PROCESS_USED_SHARED_MEMORY_NOK: |
179 |
179 |
180 /////////////////////////////////////////////////////////////////// |
180 /////////////////////////////////////////////////////////////////// |
181 // Optimization, no need to construct list if ALF is the only one |
181 // Optimization, no need to construct list if ALF is the only one |
182 /////////////////////////////////////////////////////////////////// |
182 /////////////////////////////////////////////////////////////////// |
183 |
183 |
184 if (processIds.Count() == 1) |
184 if( (processIds.Count() == 1) && (inactiveSurfaces.Count() == 1)) |
185 { |
185 { |
186 RProcess process; |
186 RProcess process; |
187 TInt err = process.Open(processIds[0]); |
187 TInt err = process.Open(processIds[0]); |
188 if(!err) |
188 if(!err) |
189 { |
189 { |
190 TInt secureId = process.SecureId(); |
190 TInt secureId = process.SecureId(); |
191 process.Close(); |
191 process.Close(); |
192 if(secureId == 0x10003B20) // magic, wserv |
192 if(secureId == 0x10003B20) // magic, wserv |
193 { |
193 { |
194 processIds.Close(); |
194 processIds.Close(); |
|
195 privMemUsed.Close(); |
195 TRACES("Only WServ using GFX mem, no need for app actions"); |
196 TRACES("Only WServ using GFX mem, no need for app actions"); |
196 return; |
197 return; |
197 } |
198 } |
198 } |
199 } |
199 } |
200 } |
200 } |
201 // } |
201 |
202 |
202 // Refresh window group list |
203 // Refresh window group list |
203 // get all window groups, with info about parents |
204 // get all window groups, with info about parents |
204 TInt numGroups = iWs.NumWindowGroups(); |
205 TInt numGroups = iWs.NumWindowGroups(); |
205 iWgIds.ReserveL(numGroups); |
206 iWgIds.ReserveL(numGroups); |
248 TInt index = iWgIds.Count(); |
249 TInt index = iWgIds.Count(); |
249 |
250 |
250 while (index--) |
251 while (index--) |
251 { |
252 { |
252 //Remove if process is not in list of processes using gfx mem |
253 //Remove if process is not in list of processes using gfx mem |
|
254 TUint secureId = AppId(index,ETrue); |
253 TBool found = 0; |
255 TBool found = 0; |
254 TInt i = 0; |
256 TInt i = 0; |
|
257 //todo - do we really need to check this list , when we have all ids in inactiveSurfaces[] |
255 for(i = 0; i < processIds.Count(); i++) |
258 for(i = 0; i < processIds.Count(); i++) |
256 { |
259 { |
257 TUint secureId = AppId(index,ETrue); |
|
258 RProcess process; |
260 RProcess process; |
259 TInt er = process.Open(processIds[i]); |
261 TInt er = process.Open(processIds[i]); |
260 if(er != KErrNone) |
262 if(er != KErrNone) |
261 { |
263 { |
262 TRACES2("RefreshL Error opening process handle %d, err %d", index, er); |
264 TRACES2("RefreshL Error opening process handle %d, err %d", index, er); |
272 TRACES3("RefreshL Process id %x, wgid %d, using gfx memory %d. Added to list", psecid, iWgIds[index].iId, privMemUsed[i]); |
274 TRACES3("RefreshL Process id %x, wgid %d, using gfx memory %d. Added to list", psecid, iWgIds[index].iId, privMemUsed[i]); |
273 break; |
275 break; |
274 } |
276 } |
275 process.Close(); |
277 process.Close(); |
276 } |
278 } |
277 TRACES1("Checking WG ID : %d", iWgIds[index].iId); |
279 |
278 for(TInt ii = 0; ii < inactiveSurfaces.Count(); ii++) |
280 if(!found) |
279 { |
281 { |
280 if (iWgIds[index].iId == inactiveSurfaces[ii] ) |
282 TRACES1("Checking WG ID : %d", iWgIds[index].iId); |
281 { |
283 for(TInt ii = 0; ii < inactiveSurfaces.Count(); ii++) |
282 AppId(index,EFalse); // update iWgName for found only |
284 { |
283 found = ETrue; |
285 if (iWgIds[index].iId == inactiveSurfaces[ii] ) |
284 TRACES2("Found %d isSystem: %d",inactiveSurfaces[ii], iWgName->IsSystem()) |
286 { |
285 } |
287 found = ETrue; |
286 } |
288 TRACES3("Found %d , AppId %x, isSystem: %d",inactiveSurfaces[ii], secureId, iWgName->IsSystem()) |
287 |
289 } |
288 if(!found || iWgName->IsSystem()) |
290 } |
|
291 } |
|
292 |
|
293 if(!found) |
289 { |
294 { |
290 iWgIds.Remove(index); |
295 iWgIds.Remove(index); |
291 continue; |
296 continue; |
292 } |
297 } |
293 } |
298 |
294 |
299 //check if it is system app |
295 |
300 if(iWgName->IsSystem() /*|| iWgName->Hidden()*/) |
296 processIds.Close(); |
301 { |
|
302 TRACES3("System/Hidden app found %x, ISystem %d, IsHidden %d",secureId, iWgName->IsSystem()?1:0, iWgName->Hidden()?1:0); |
|
303 sparedProcessIds.Append(secureId); |
|
304 } |
|
305 |
|
306 } |
|
307 |
|
308 inactiveSurfaces.Close(); |
|
309 //CleanupStack::PopAndDestroy(); // CleanupClosePushL(inactiveSurfaces); |
|
310 processIds.Close(); |
297 privMemUsed.Close(); |
311 privMemUsed.Close(); |
298 |
312 |
|
313 //check if any system apps are included |
299 index = iWgIds.Count(); |
314 index = iWgIds.Count(); |
300 while (index--) |
315 while (index--) |
301 { |
316 { |
|
317 TBool skipped = EFalse; |
|
318 for(TInt i = 0; i < sparedProcessIds.Count(); i++) |
|
319 { |
|
320 if(AppId(index,ETrue) == sparedProcessIds[i]) |
|
321 { |
|
322 TRACES2("WgId %d belongs to system app %x. Removing from Kill List",iWgIds[index].iId, sparedProcessIds[i]); |
|
323 iWgIds.Remove(index); |
|
324 skipped = ETrue; |
|
325 break; |
|
326 } |
|
327 } |
|
328 |
|
329 if(skipped) |
|
330 continue; |
|
331 |
302 // See if there is a tick count entry for each window in the list |
332 // See if there is a tick count entry for each window in the list |
303 TGOomWindowGroupProperties* wgProperties = iWgToPropertiesMapping.Find(iWgIds[index].iId); |
333 TGOomWindowGroupProperties* wgProperties = iWgToPropertiesMapping.Find(iWgIds[index].iId); |
304 |
334 |
305 if (!wgProperties) |
335 if (!wgProperties) |
306 { |
336 { |
309 // If there is no idle tick entry for this window then add one |
339 // If there is no idle tick entry for this window then add one |
310 iWgToPropertiesMapping.InsertL(iWgIds[index].iId, wgProperties); |
340 iWgToPropertiesMapping.InsertL(iWgIds[index].iId, wgProperties); |
311 } |
341 } |
312 } |
342 } |
313 TRACES1("Number of applications using graphics mem: %d", iWgIds.Count()); |
343 TRACES1("Number of applications using graphics mem: %d", iWgIds.Count()); |
|
344 sparedProcessIds.Close(); |
314 } |
345 } |
315 |
346 |
316 |
347 |
317 |
348 |
318 void CGOomWindowGroupList::RemovePropertiesForClosedWindowsL() |
349 void CGOomWindowGroupList::RemovePropertiesForClosedWindowsL() |