Repository: godot
Issue: Occasional 32bit editor crashes in Windows: malloc returns null.  Memory leak?
Labels: bug,platform:windows,topic:core,topic:editor,crash

### Godot version

3.5 custom, 32bit editor

### System information

Windows 10, GLES3, NVidia RTX 3080

### Issue description

Every once in a while, often when importing things, the editor will crash because it fails to allocate memory.  In task manager, the editor usually isn't using that much memory (usually 50-300 megs), so it shouldn't be a problem to allocate the few megs requested.  I opened it up in VMMap after a failure to allocate about 8 megs, and this is what I found:

![image](https://user-images.githubusercontent.com/7751182/172744607-e31bc734-1a4e-4f10-b915-2db816d4ecc1.png)

Not sure what all the "Private Data" is.  I don't think this happens in the 64bit version, as there is more memory space to address, but it might be a sign of some sort of memory leak that warrants investigation.  My project really shouldn't be using THAT much memory and should be safe in a 32bit version.

In Task Manager, it's only using a couple hundred megs:
![image](https://user-images.githubusercontent.com/7751182/172745318-1a0c576a-4435-4ed0-ba72-3bad09271f39.png)

### Steps to reproduce

Nothing really specific -- sometimes importing new meshes or textures will do it.  I just now got it from simply trying to run from the editor.  This was the call stack:

```
 	godot.windows.opt.tools.32.exe!_err_print_error(const char * p_function, const char * p_file, int p_line, const char * p_error, ErrorHandlerType p_type) Line 69	C++
>	godot.windows.opt.tools.32.exe!Memory::alloc_static(unsigned int p_bytes, bool p_pad_align) Line 77	C++
 	godot.windows.opt.tools.32.exe!PoolVector<unsigned char>::resize(int p_size) Line 563	C++
 	godot.windows.opt.tools.32.exe!RasterizerStorageGLES3::texture_get_data(RID p_texture, int p_layer) Line 1159	C++
 	godot.windows.opt.tools.32.exe!VisualServerRaster::texture_get_data(RID arg1, int arg2) Line 147	C++
 	godot.windows.opt.tools.32.exe!VisualServerWrapMT::texture_get_data(RID p1, int p2) Line 85	C++
 	godot.windows.opt.tools.32.exe!ViewportTexture::get_data() Line 121	C++
 	godot.windows.opt.tools.32.exe!EditorNode::_save_scene_with_preview(String p_file, int p_idx) Line 1351	C++
 	godot.windows.opt.tools.32.exe!EditorNode::_save_all_scenes() Line 1625	C++
 	godot.windows.opt.tools.32.exe!EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) Line 2440	C++
 	[Inline Frame] godot.windows.opt.tools.32.exe!EditorNode::_menu_option(int) Line 1104	C++
 	godot.windows.opt.tools.32.exe!EditorNode::_run(bool p_current, const String & p_custom) Line 2206	C++
 	[Inline Frame] godot.windows.opt.tools.32.exe!EditorNode::run_play() Line 4712	C++
 	godot.windows.opt.tools.32.exe!EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) Line 2570	C++
 	godot.windows.opt.tools.32.exe!EditorNode::_menu_option(int p_option) Line 1105	C++
 	godot.windows.opt.tools.32.exe!MethodBind1<EditorNode,int>::call(Object * p_object, const Variant * * p_args, int p_arg_count, Variant::CallError & r_error) Line 867	C++
 	godot.windows.opt.tools.32.exe!Object::call(const StringName & p_method, const Variant * * p_args, int p_argcount, Variant::CallError & r_error) Line 918	C++
 	godot.windows.opt.tools.32.exe!Object::emit_signal(const StringName & p_name, const Variant * * p_args, int p_argcount) Line 1224	C++
 	godot.windows.opt.tools.32.exe!Object::emit_signal(const StringName & p_name, const Variant & p_arg1, const Variant & p_arg2, const Variant & p_arg3, const Variant & p_arg4, const Variant & p_arg5) Line 1280	C++
 	godot.windows.opt.tools.32.exe!BaseButton::_pressed() Line 128	C++
 	godot.windows.opt.tools.32.exe!BaseButton::on_action_event(Ref<InputEvent> p_event) Line 168	C++
 	godot.windows.opt.tools.32.exe!BaseButton::_gui_input(Ref<InputEvent> p_event) Line 81	C++
 	godot.windows.opt.tools.32.exe!MethodBind1<BaseButton,Ref<InputEvent>>::call(Object * p_object, const Variant * * p_args, int p_arg_count, Variant::CallError & r_error) Line 867	C++
 	godot.windows.opt.tools.32.exe!Object::call_multilevel(const StringName & p_method, const Variant * * p_args, int p_argcount) Line 766	C++
 	godot.windows.opt.tools.32.exe!Object::call_multilevel(const StringName & p_name, const Variant & p_arg1, const Variant & p_arg2, const Variant & p_arg3, const Variant & p_arg4, const Variant & p_arg5) Line 864	C++
 	godot.windows.opt.tools.32.exe!Viewport::_gui_call_input(Control * p_control, const Ref<InputEvent> & p_input) Line 1645	C++
 	godot.windows.opt.tools.32.exe!Viewport::_gui_input_event(Ref<InputEvent> p_event) Line 2031	C++
 	godot.windows.opt.tools.32.exe!Viewport::input(const Ref<InputEvent> & p_event) Line 2846	C++
 	godot.windows.opt.tools.32.exe!Viewport::_vp_input(const Ref<InputEvent> & p_ev) Line 1412	C++
 	godot.windows.opt.tools.32.exe!MethodBind1<Viewport,Ref<InputEvent> const &>::call(Object * p_object, const Variant * * p_args, int p_arg_count, Variant::CallError & r_error) Line 867	C++
 	godot.windows.opt.tools.32.exe!Object::call(const StringName & p_method, const Variant * * p_args, int p_argcount, Variant::CallError & r_error) Line 918	C++
 	godot.windows.opt.tools.32.exe!Object::call(const StringName & p_name, const Variant & p_arg1, const Variant & p_arg2, const Variant & p_arg3, const Variant & p_arg4, const Variant & p_arg5) Line 849	C++
 	godot.windows.opt.tools.32.exe!SceneTree::call_group_flags(unsigned int p_call_flags, const StringName & p_group, const StringName & p_function, const Variant & p_arg1, const Variant & p_arg2, const Variant & p_arg3, const Variant & p_arg4, const Variant & p_arg5) Line 280	C++
 	godot.windows.opt.tools.32.exe!SceneTree::input_event(const Ref<InputEvent> & p_event) Line 439	C++
 	godot.windows.opt.tools.32.exe!InputDefault::_parse_input_event_impl(const Ref<InputEvent> & p_event, bool p_is_emulated) Line 491	C++
 	godot.windows.opt.tools.32.exe!InputDefault::flush_buffered_events() Line 711	C++
 	[Inline Frame] godot.windows.opt.tools.32.exe!OS_Windows::process_events() Line 2566	C++
 	godot.windows.opt.tools.32.exe!OS_Windows::run() Line 3396	C++
 	godot.windows.opt.tools.32.exe!widechar_main(int argc, wchar_t * * argv) Line 161	C++
 	godot.windows.opt.tools.32.exe!_main() Line 183	C++
 	godot.windows.opt.tools.32.exe!main(int _argc, char * * _argv) Line 195	C++
 	[External Code]	
```
data_size = 4757496 when it was trying to call data.resize(data_size * 2); //add some memory at the end, just in case for buggy drivers