Jump to content
View in the app

A better way to browse. Learn more.

Tuts 4 You

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

low-fragmentation heap (LFH) C#

Featured Replies

Posted

The low-fragmentation heap (LFH) helps to reduce heap fragmentation.

The LFH is not a separate heap. Instead, it is a policy that applications

can enable for their heaps. When the LFH is enabled, the system allocates

memory in certain predetermined sizes. When an application requests a memory allocation

from a heap that has the LFH enabled, the system allocates the smallest block of memory

that is large enough to contain the requested size. The system does not use the LFH for

allocations larger than 16 KB, whether or not the LFH is enabled.

// C# code:

// Imports:

[DllImport("kernel32.dll")]

private static extern uint GetProcessHeaps(uint NumberOfHeaps,

IntPtr[] ProcessHeaps);

[DllImport("kernel32.dll", SetLastError = true)]

private unsafe static extern uint HeapSetInformation(

IntPtr HeapHandle,

int HeapInformationClass,

void *HeapInformation,

uint HeapInformationLength

);

private const int HeapCompatibilityInformation = 0;

public static void SetLFH()

{

uint hcount = GetProcessHeaps(0,null);

IntPtr[] aheaps = new IntPtr[hcount];

hcount = GetProcessHeaps(hcount,aheaps);

uint info = 2;

IntPtr cac = GetProcessHeap();

for (uint i=0;i<hcount;i++)

{

try

{

// Enable the low-fragmentation heap (LFH)

HeapSetInformation(aheaps,

HeapCompatibilityInformation,

(void *)&info,

sizeof(uint));

}

catch

{

// If that method isn't available, like on Win2K,

// don't worry about it.

}

}

}

An the Private bytes increase whit 2 MB and performance is not increased

WTF ? :dunno:

Edited by CodeRipper

Create an account or sign in to comment

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.