Skip to main content

Questions tagged [memory]

Questions related to memory use in Solidity or by nodes

Filter by
Sorted by
Tagged with
0 votes
1 answer
33 views

return array of size n

I need a function that willl return an array of size n and have each element be a 1. How do I write this in solidity? I need something like uint256[] a = makeOnesArray(5) => [1, 1, 1, 1, 1]
degendeveloper's user avatar
0 votes
1 answer
683 views

Initialising an array with a single value in solidity

I want to create an array of all 1's. As per my understanding, doing it manually after declaration through a for loop will lead to high gas expense. So, is there any way to initialize an array at once,...
Hrishabh's user avatar
0 votes
1 answer
72 views

Data location memory or calldata [duplicate]

Can someone tell me how to solve this problem? I am not advanced and cannot figure it out.
Matthew's user avatar
0 votes
1 answer
215 views

Using storage for local function variables

In one function, I was forced to declare a variable with the memory type storage (since there is mapping inside the struct). Is it much more expensive than memory? And how justified is it if I will ...
Nikita Rov's user avatar
0 votes
1 answer
36 views

why x(function setArr) is not being returned?

pragma solidity >=0.5.0 <0.7.0; contract Example{ uint256[3] x; function setArr(uint256[3] memory y) public returns(uint256[3] memory){ x=y; return getArr(x); } ...
user61878's user avatar
0 votes
1 answer
32 views

Understanding data location

pragma solidity ^0.5.16; contract mycontract{ uint256 public a; function foo(string calldata _name) external { string memory names; names = _name; getname(names); ...
user61878's user avatar
0 votes
0 answers
616 views

Memory Arrays Should Have Push() And Pop()

Dynamic memory arrays currently cannot be resized. This is true for Solang and solc solidity. However, Solang uses a heap, and has a realloc() function. Thus it is is possible for Solang to support ...
user60454's user avatar
0 votes
0 answers
51 views

How to save/read mappings within struct?

I am trying to create a mapping inside struct and then create a mapping of the struct. Take a look at below example: // ------------------------------------------------------------------------ ...
Fariha Abbasi's user avatar
0 votes
1 answer
584 views

error: data location must be storage or memory for parameter in funtion but none was given solidity [duplicate]

pragma solidity ^0.5.0; contract Election{ //model a candidates struct candidate { uint id; string name; uint votecount; } //store candidates //fetch candidate mapping(uint =...
cosmas's user avatar
  • 11
0 votes
0 answers
1k views

FATAL ERROR: Rebalance Allocation failed - process out of memory

So while running truffle compile for my contracts on AWS Ubuntu server I got the following error: <--- Last few GCs ---> [17055:0x3985730] 11958 ms: Scavenge 511.7 (553.4) -> 506.9 (553.4) ...
Gagan's user avatar
  • 433
0 votes
1 answer
819 views

how to replace an array in a mapping?

I'm learning solidity right now and making a dApp where users get paid to perform actions. Actions are paid based on certain criteria. Since I can't schedule a cron job on ethereum, I can only pay ...
Terence Chow's user avatar
0 votes
1 answer
467 views

Solidity memory pointer

Is there any way I can use a local parameter within multiple functions? The idea is to save gas when calling functions. A parameter wouldn't have to be copied and be returned every time. Here's some ...
Chris's user avatar
  • 1,302

1 2 3 4
5