What is the maximal dimension of a linear subspace $ V$ of the vector space of real $ n \times n$ matrices such that for all $ A$ in $ B$ in $ V$, we have $ \text{trace}\left(AB\right) \equal{} 0$ ?
1. **Define the Problem in Terms of Bilinear Forms:**
   We start by noting that the trace function $\text{trace}(AB)$ defines a symmetric bilinear form on the space of $n \times n$ real matrices, denoted as $Mat_n(\mathbb{R})$. Specifically, for matrices $A, B \in Mat_n(\mathbb{R})$, we define the bilinear form $(A, B) := \text{trace}(AB)$.

2. **Properties of the Bilinear Form:**
   The bilinear form $(A, B) := \text{trace}(AB)$ is symmetric because $\text{trace}(AB) = \text{trace}(BA)$ for any matrices $A$ and $B$. This symmetry implies that the form is well-suited for analysis using tools from the theory of quadratic forms and orthogonal spaces.

3. **Decomposition Using Witt's Theorem:**
   According to Witt's theorem, any symmetric bilinear form on a vector space over a field can be decomposed into a direct sum of orthogonal subspaces. For the space $Mat_n(\mathbb{R})$, this decomposition is:
   \[
   Mat_n(\mathbb{R}) = L_0 \oplus L_{an} \oplus L_h
   \]
   where:
   - $L_0$ is the kernel of the bilinear form (matrices $A$ such that $\text{trace}(AB) = 0$ for all $B$),
   - $L_{an}$ is the anisotropic part (contains no isotropic vectors),
   - $L_h$ is the hyperbolic part (contains pairs of isotropic vectors).

4. **Analyzing the Kernel $L_0$:**
   We claim that $L_0 = 0$. To see why, consider any non-zero matrix $A$. We can always find a matrix $B$ such that $\text{trace}(AB) \neq 0$. For example, if $A$ has a non-zero entry $a_{ij}$, we can choose $B$ to be a matrix with a $1$ in the $(j,i)$ position and zeros elsewhere. This choice ensures that $\text{trace}(AB) = a_{ij} \neq 0$. Hence, $L_0 = 0$.

5. **Dimension of $L_{an}$:**
   The anisotropic part $L_{an}$ contains all diagonal matrices because no diagonal matrix can be isotropic (i.e., $\text{trace}(A^2) \neq 0$ for any non-zero diagonal matrix $A$). The dimension of the space of diagonal matrices is $n$, so $\dim L_{an} \geq n$.

6. **Dimension of $L_h$:**
   Since $L_0 = 0$, the remaining part of the space is $L_{an} \oplus L_h$. The total dimension of $Mat_n(\mathbb{R})$ is $n^2$, so:
   \[
   \dim L_{an} + \dim L_h = n^2
   \]
   Given that $\dim L_{an} \geq n$, it follows that:
   \[
   \dim L_h \leq n^2 - n = n(n-1)
   \]

7. **Maximal Isotropic Subspace:**
   We seek the dimension of a maximal isotropic subspace $V$ within $Mat_n(\mathbb{R})$. A maximal isotropic subspace in $L_h$ (since $L_{an}$ contains no isotropic vectors) must have a hyperbolic counterpart. By a well-known lemma in the theory of quadratic forms, the dimension of any maximal isotropic subspace $V$ satisfies:
   \[
   2 \dim V \leq \dim L_h \leq n(n-1)
   \]
   Therefore:
   \[
   \dim V \leq \frac{n(n-1)}{2}
   \]

8. **Example to Achieve the Bound:**
   The space of upper triangular matrices (excluding the diagonal) provides an example of a subspace where $\text{trace}(AB) = 0$ for all $A, B$ in the subspace. The dimension of this subspace is indeed $\frac{n(n-1)}{2}$, showing that the bound is achievable.

Conclusion:
\[
\boxed{\frac{n(n-1)}{2}}
\]