Root > Reference > All Functions > MemWipeStack

Procedure MemWipeStack

Previous pageReturn to chapter overviewNext page   

Clears unused stack of the current thread.







Code (Delphi)

procedure MemWipeStack;



This function wipes (clears) the content of the unused part of the stack. The wipe is performed with debug pattern ($CCCCCCCC).


This means that when execution goes further - the uninitialized local variables will have non-0, non-nil, unaccessible value. This can help catch use of uninitialized variables.


Additionally, clearing stack can help to reduce number of false-positive entries with RAW stack tracing.


We recommend to call this function from time to time. For example, when application is idle, or about to do some heavy work.



It is highly recommended to call the function first to determinate if the MemWipeStack function should be called.



This function clears the entire unused stack to the end. E.g. if you use 1 Mb stack (default) - then 1 Mb of memory will be written (except the busy part of the stack). Therefore, do not call this function too frequently, otherwise your performance will suffer.


Use with caution when stack size is greatly increased.




Code (Delphi)

procedure TForm1.ClearStackOnIdle(Sender: TObject; var Done: Boolean);


if CanCallMemWipeStack then


Done := True;


procedure TForm1.FormCreate(Sender: TObject);


Application.OnIdle := Self.ClearStackOnIdle;



See also

Send feedback... Build date: 2022-03-28
Last edited: 2022-03-28
The documentation team uses the feedback submitted to improve the EurekaLog documentation. We do not use your e-mail address for any other purpose. We will remove your e-mail address from our system after the issue you are reporting has been resolved. While we are working to resolve this issue, we may send you an e-mail message to request more information about your feedback. After the issues have been addressed, we may send you an email message to let you know that your feedback has been addressed.

Permanent link to this article: