Skip to content

Handle "out of memory" situation in Tr2CurveLineSet - #127

Open
filipppavlov wants to merge 2 commits into
mainfrom
curvelineset-fix
Open

filipppavlov wants to merge 2 commits into
mainfrom
curvelineset-fix

Conversation

@filipppavlov

Copy link
Copy Markdown
Member

Summary

We are observing crashes in Tr2CurveLineSet when it cannot allocate enough RAM to upload data to its
vertex buffer. Add a check and an early exit when it fails to allocate memory.

Linked issue (optional)

https://fenriscreations.atlassian.net/browse/PLAT-10759

Testing

Tested locally with an artificial repro script.

Copilot AI balanced review requested due to automatic review settings October 19, 2026 10:56

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cpp-linter Review

Used clang-format v21.1.8

Click here for the full clang-format patch
diff --git a/trinity/Tr2CurveLineSet.cpp b/trinity/Tr2CurveLineSet.cpp
index 98cb7b9..7e0bc00 100644
--- a/trinity/Tr2CurveLineSet.cpp
+++ b/trinity/Tr2CurveLineSet.cpp
@@ -378 +378 @@ bool Tr2CurveLineSet::FillVertexBuffer()
-		if ( !buffer )
+		if( !buffer )

Have any feedback or feature suggestions? Share it here.


size_t byteSize = size_t( std::max( currentNumOfLines, m_vertexBufferSize ) ) * 6 * sizeof( LineVertex );
auto buffer = Tr2Renderer::GetPoolAllocator()->Allocate( byteSize );
if ( !buffer )

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-format suggestion

Suggested change
if ( !buffer )
if( !buffer )

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Retrying after allocation failure with fewer lines can overrun the recreated vertex buffer.

1 open issue

Review effort: Balanced

// can the big vertexbuffer handle this?
int currentNumOfLines = GetNumOfLines();

size_t byteSize = size_t( std::max( currentNumOfLines, m_vertexBufferSize ) ) * 6 * sizeof( LineVertex );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants