Too much memory used when parsing nodes from assimp's structure #5321
Closed
cuppajoeman
started this conversation in
General
Replies: 1 comment
-
I had nested my indices processing loop within the vertex iteration causing a huge number of extraneous iterations. The skipping over already loading images optimization was not working and stbi_load was eating up a lot of time. After fixing both of those problems, I no longer have the memory issue. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Introduction
Hi there, I'm getting started with game development using c++ and have recently found assimp for model loading, I'm hoping to use it to load models and render them in opengl.
more details
I've been following the tutorials at https://learnopengl.com and I've gotten to the point where I'm trying to make a model loader that can render data from assimp to opengl. Currently I'm using
glfw
,stb_image.h
andglm
in my project.I decided to post on these discussion boards, because I believe that many members of this community may have built something similar and may be able catch any flaws in how I'm parsing the assimp structure. If this is not the place to post this, please let me know where else I could.
Computer Specs
I have a linux computer running manjaro it has 16gb of ram.
I've built assimp as a shared library, I'm not building my program in debug mode
Goal
I'm currently trying to load in this obj file mentioned in the tutorial, and I'm not trying to do any fancy lighting, so I'm just trying to parse the diffuse maps from the model to use as a flat unlighted texture.
Issue
I've written code based on it's done in the tutorial, but whenever I run my code that parses the assimp structure I believe there is a memory problem because after only loading a few meshes I get a
killed
message in the terminal and my programs stops.Supporting evidence that this is a memory issue
I believe this is a memory problem because when I searched online for other people's experience with a
killed
message, they mentioned it usually happens when the program tries to re-allocate a continuous block of memory and there isn't enough space. To this end I believe that maybe I'm trying to load too much data from assimp into mymeshes
class member and eventually it needs more space, tries to double it's size and realizes there's not enough space.Also if I run the executable then and I watch memory usage on htop, it's steadily increasing as I parse the nodes over time going from 1.5gb memory usage to around 8gb before the program gets killed.
The output from GNU time shows that a lot of memory is used:
Code
Since the program gets killed before drawing occurs, I've omitted the drawing code
Currently this is how I'm processing things:
`model_loading.cpp`
For context, I start things off with a call to
Mesh::load_model(".../backpack.obj")
which from there recursively processes each node by going through the Mesh's attached to that node, and then processing all child nodes.Thank you very much for taking a look.
Beta Was this translation helpful? Give feedback.
All reactions