I need to increase stack size for editor because DebugEditor begin crash nearly the end of loading (93-95% loading) with stack overflow error.
From log I see that it loading map in that time. If I put absolutely clear map for initial load - it loads successfully. But when it load (initially) any of work maps it will crash with overflow.
So how to increase stack size for unreal engine? Because in Visual Studio 2015 on Project Property page are absent needed pages as described here: /F (Set Stack Size) | Microsoft Docs
I believe, for the editor, you want to look at VCToolChain.cs (where it uses the stack size) or UEBuildWindows.cs (where it sets “LinkEnvironment.DefaultStackSize”
A quick test showed me that stomping over it in VCToolChain.cs seemed to fix my debug editor (I made it conditional on “(LinkEnvironment.Configuration == CppConfiguration.Debug)”.
However, I’m also running out of stack when cooking, and nothing I do to either of those files seems to change my cooker stack size(trying to track down a cooker crash), so I’d appreciate any tips anyone has there.
Hi,Alex.Duran:
so lucky to meet u here. i also have a question on how to increase the stack size for UE4 like VC++. have u found some solution about it? looking forward to ur sharing. thank u.
Hi,nynjed:
so lucky to meet u here. i also have a question on how to increase the stack size for UE4 like VC++. have u found some solution to it? looking forward to ur sharing. thank u.
I am not used this now but some engine updates ago I made changes to LinkEnvironment.cs and UEBuildWindows.cs.
In this files I found “DefaultStackSize” variable and assign it required size.
there 2 places in LinkEnvironment.cs which become like:
[RequiresUniqueBuildEnvironment]
[ConfigFile(ConfigHierarchyType.Engine, "/Script/WindowsTargetPlatform.WindowsTargetSettings")]
public int DefaultStackSize = 25000000;
public int DefaultStackSize
{
get { return 25000000/*Inner.DefaultStackSize*/; }
}
Im not sure which of this changes actually enough to work so changed in all found places just in case.
Hi Alex:
Thanks for ur reply, so helpful. I found it finally in LinkEnvironment.cs as follows.
///
/// The default stack memory size allocation
///
public int DefaultStackSize = 5000000;
Can i ask one more question? what’ the unit of DefaultStackSize? bit or byte. actually, i think 5000000 is enough. can u give me a recommended number? Thanks a lot.
Hi nynjed:
Thanks for ur reply, so helpful. I found it finally in LinkEnvironment.cs as follows.
///
/// The default stack memory size allocation
///
public int DefaultStackSize = 5000000;
Can i ask one more question? what’ the unit of DefaultStackSize? bit or byte. actually, i think 5000000 is enough. can u give me a recommended number? Thanks a lot.
This options is configurable via *Engine.ini file:
e.g. ..\UnrealEngine\Engine\Config\BaseEngine.ini
[/Script/WindowsTargetPlatform.WindowsTargetSettings]
DefaultStackSize=48000000
; Default value is 12000000
P.S. You can also use ..\Game\Config\DefaultEngine.ini but tools might complain that you override shared binaries i.e. your build might use binaries directly from /Engine/… folder, which is available for other projects too. So Engine-related config changes in specific project’s .ini file leads to compilation of “new version” of binaries which is surprise for other projects that also depends on common “/Engine/ stuff”. As a solution you can set Unique build environment option in your project’s TargetRules.cs file:
BuildEnvironment = TargetBuildEnvironment.Unique;
It will compile /Engine/ stuff directly into your project’s folder instead of touching shared one. Ofc it will take some time to compile (almost like full engine recompile).