Yuji
Yuji
Explore posts from servers
CC#
Created by Yuji on 3/7/2025 in #help
✅ Memory leak or What?
u dont have permssion iit says
114 replies
CC#
Created by Yuji on 3/7/2025 in #help
✅ Memory leak or What?
i dont have permission :/
114 replies
CC#
Created by Yuji on 3/7/2025 in #help
✅ Memory leak or What?
also how to close this
114 replies
CC#
Created by Yuji on 3/7/2025 in #help
✅ Memory leak or What?
bye
114 replies
CC#
Created by Yuji on 3/7/2025 in #help
✅ Memory leak or What?
Thanks for time and effort everyone, espicially cap5slut Have a great evening/day :]
114 replies
CC#
Created by Yuji on 3/7/2025 in #help
✅ Memory leak or What?
if something happens I will notify in this thread if i can
114 replies
CC#
Created by Yuji on 3/7/2025 in #help
✅ Memory leak or What?
Anyways I will run that thing on docker and monitor in constraint resources
114 replies
CC#
Created by Yuji on 3/7/2025 in #help
✅ Memory leak or What?
So here metadata of vector will be in stack
114 replies
CC#
Created by Yuji on 3/7/2025 in #help
✅ Memory leak or What?
Without new
114 replies
CC#
Created by Yuji on 3/7/2025 in #help
✅ Memory leak or What?
-----------------------
std::vector<int>()
-----------------------
stack address is 1000 (metadata stored here)

std::vector<int> v1; // v1 is created on stack at address 1000

std::vector<int> v2 = v1; // Copy constructor is invoked
// A new vector is created with the same content as v1
// Stored at a different stack address (e.g., 2000)
// A new heap allocation is done for the elements

So in the end:

-----------------------
std::vector<int> (v1)
-----------------------
stack address is 1000
heap address (data) is 3000

-----------------------
std::vector<int> (v2)
-----------------------
stack address is 2000
heap address (data) is 4000 (copied from 3000)

And if you modify v1, it will not reflect in v2
-----------------------
std::vector<int>()
-----------------------
stack address is 1000 (metadata stored here)

std::vector<int> v1; // v1 is created on stack at address 1000

std::vector<int> v2 = v1; // Copy constructor is invoked
// A new vector is created with the same content as v1
// Stored at a different stack address (e.g., 2000)
// A new heap allocation is done for the elements

So in the end:

-----------------------
std::vector<int> (v1)
-----------------------
stack address is 1000
heap address (data) is 3000

-----------------------
std::vector<int> (v2)
-----------------------
stack address is 2000
heap address (data) is 4000 (copied from 3000)

And if you modify v1, it will not reflect in v2
114 replies
CC#
Created by Yuji on 3/7/2025 in #help
✅ Memory leak or What?
-----------------------
new std::vector<int>()
-----------------------
Heap address is 1000

auto v1 = new std::vector<int>() // returns start addrees means 1000
auto v2 = v1 // Points to 1000

So in the end

-----------------------
new std::vector<int>()
-----------------------
Heap address is 1000

It is pointed by both v1 and v2

And if you modify in v1 it will reflect v2 because they pointing to same stuff
-----------------------
new std::vector<int>()
-----------------------
Heap address is 1000

auto v1 = new std::vector<int>() // returns start addrees means 1000
auto v2 = v1 // Points to 1000

So in the end

-----------------------
new std::vector<int>()
-----------------------
Heap address is 1000

It is pointed by both v1 and v2

And if you modify in v1 it will reflect v2 because they pointing to same stuff
114 replies
CC#
Created by Yuji on 3/7/2025 in #help
✅ Memory leak or What?
content of v1
114 replies
CC#
Created by Yuji on 3/7/2025 in #help
✅ Memory leak or What?
It will copy in above code
114 replies
CC#
Created by Yuji on 3/7/2025 in #help
✅ Memory leak or What?
auto v1 = std::vector<int>;
// fill v1
auto v2 = v1;
auto v1 = std::vector<int>;
// fill v1
auto v2 = v1;
If its this then it will copy
114 replies
CC#
Created by Yuji on 3/7/2025 in #help
✅ Memory leak or What?
v2 will be also pointer
114 replies
CC#
Created by Yuji on 3/7/2025 in #help
✅ Memory leak or What?
here v1 will be pointer
114 replies
CC#
Created by Yuji on 3/7/2025 in #help
✅ Memory leak or What?
nope
114 replies
CC#
Created by Yuji on 3/7/2025 in #help
✅ Memory leak or What?
But that language is also nightmarish to deal with
114 replies
CC#
Created by Yuji on 3/7/2025 in #help
✅ Memory leak or What?
c++ is better atleast u know when you allocating somethin -_-
114 replies
CC#
Created by Yuji on 3/7/2025 in #help
✅ Memory leak or What?
T-T i accidently shared same thing so only 1
114 replies