Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Developing U++ » U++ Developers corner » U++ Allocator & Vulkan
Re: U++ Allocator & Vulkan [message #57464 is a reply to message #57463] Sun, 22 August 2021 16:50 Go to previous message
Xemuth is currently offline  Xemuth
Messages: 387
Registered: August 2018
Location: France
Senior Member
mirek wrote on Sun, 22 August 2021 09:37


U++ allocator aligns to 16 bytes. More likely Vulkan is calling new/delete and it is "system" new/delete - there is no solution to the problem AFAIK. Same issue we encountered on macos; partial solution is to use U++ allocator where U++ is using it directly (which is still plentiful) and use standard new/delete elsewhere. I think it is flagSTDNEWDELETE - check PLATFORM_MACOS.


Hello Mirek, thanks for your time.
To prevent the fact Vulkan would use system new/delete instead of U++ one. I did a Custom memory allocator for Vulkan (Vulkan allow you to set up some callback to execute in order to allocate memory instead of using Vulkan default way.

Here is my 2 memory functions :

void* UVkCustomAllocator::DefaultAllocation(size_t size, size_t alignement, VkSystemAllocationScope allocationScope){
	void* ptr;
	if(alignement < size){
		ptr = malloc(size);
		ASSERT_(ptr, "Error during malloc for size of " +  AsString(size));
	}else{
		int rc = posix_memalign(&ptr, alignement, size);
		ASSERT_(rc == 0,"Error code : "+ AsString(rc) +" during posix_memalign for size of " +  AsString(size) + " and alignement of " + AsString(alignement));
	}
    return ptr;
}

void  UVkCustomAllocator::DefaultFree(void* pMemory){
	if(pMemory){
		return free(pMemory);
	}
}

Thoses functions are really simple and is based on malloc and posix_memalign. Right after implementing this (Test with some LOG), all my Vulkan call to allocate some memory use boths functions.
After tracking each malloc and free call, all the memory allocated by vulkan are correctly freed. So I don't understand why I still have some memory leaks when Vulkan don't use U++ allocator ? (or maybe I think he don't use it anymore)

PS: Moreover, when I launch my test program on Windows, (without USEMALLOC flag) I don't have any memory leak (CLANG / MVSC)
PS2: Using USEMALLOC or STD_NEWDELETE work fine even without custom memory allocator

[Updated on: Sun, 22 August 2021 16:55]

Report message to a moderator

 
Read Message
Read Message
Read Message
Previous Topic: set up ide minimize option when Execute (Ctrl + F5)
Next Topic: Refining IsNull(double)
Goto Forum:
  


Current Time: Sun Jun 01 10:45:45 CEST 2025

Total time taken to generate the page: 0.02892 seconds