Changeset 180666 in webkit


Ignore:
Timestamp:
Feb 26, 2015 12:15:04 AM (9 years ago)
Author:
akling@apple.com
Message:

[Cocoa] Prod libcache to drop caches in memory pressure relief handler.
<https://webkit.org/b/142024>
<rdar://problem/19966096>

Reviewed by Antti Koivisto.

libcache already listens to the OS memory pressure notifications, but we still
need to manually request a cleanup when doing an iOS process suspension, or when
simulating memory pressure.

  • platform/cocoa/MemoryPressureHandlerCocoa.mm:

(WebCore::MemoryPressureHandler::platformReleaseMemory): Call out to libcache's
cache_simulate_memory_warning_event() to make sure that nonessential objects
being kept alive by NSCaches get dropped when we need the memory.

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r180661 r180666  
     12015-02-26  Andreas Kling  <akling@apple.com>
     2
     3        [Cocoa] Prod libcache to drop caches in memory pressure relief handler.
     4        <https://webkit.org/b/142024>
     5        <rdar://problem/19966096>
     6
     7        Reviewed by Antti Koivisto.
     8
     9        libcache already listens to the OS memory pressure notifications, but we still
     10        need to manually request a cleanup when doing an iOS process suspension, or when
     11        simulating memory pressure.
     12
     13        * platform/cocoa/MemoryPressureHandlerCocoa.mm:
     14        (WebCore::MemoryPressureHandler::platformReleaseMemory): Call out to libcache's
     15        cache_simulate_memory_warning_event() to make sure that nonessential objects
     16        being kept alive by NSCaches get dropped when we need the memory.
     17
    1182015-02-25  Zalan Bujtas  <zalan@apple.com>
    219
  • trunk/Source/WebCore/platform/cocoa/MemoryPressureHandlerCocoa.mm

    r180225 r180666  
    11/*
    2  * Copyright (C) 2011-2014 Apple Inc. All Rights Reserved.
     2 * Copyright (C) 2011-2015 Apple Inc. All Rights Reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    4545#endif
    4646
     47extern "C" void cache_simulate_memory_warning_event(uint64_t);
     48
    4749namespace WebCore {
    4850
    49 void MemoryPressureHandler::platformReleaseMemory(bool)
     51void MemoryPressureHandler::platformReleaseMemory(bool critical)
    5052{
    5153    {
     
    5961        IOSurfacePool::sharedPool().discardAllSurfaces();
    6062    }
     63#endif
     64
     65#if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
     66    if (critical && !isUnderMemoryPressure()) {
     67        // libcache listens to OS memory notifications, but for process suspension
     68        // or memory pressure simulation, we need to prod it manually:
     69        ReliefLogger log("Purging libcache caches");
     70        cache_simulate_memory_warning_event(DISPATCH_MEMORYPRESSURE_CRITICAL);
     71    }
     72#else
     73    UNUSED_PARAM(critical);
    6174#endif
    6275
Note: See TracChangeset for help on using the changeset viewer.